diff --git a/.golangci.yaml b/.golangci.yaml index ad831fe5f..770e32597 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -41,6 +41,16 @@ linters-settings: alias: policy - pkg: github.com/arangodb/kube-arangodb/pkg/apis/shared/v1 alias: sharedApi + - pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1 + alias: schedulerApi + - pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/container + alias: schedulerContainerApi + - pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/container/resources + alias: schedulerContainerResourcesApi + - pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/pod + alias: schedulerPodApi + - pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/pod/resources + alias: schedulerPodResourcesApi - pkg: github.com/arangodb/kube-arangodb/pkg/apis/shared alias: shared - pkg: github.com/arangodb/kube-arangodb/pkg/handlers/enterprise/ml/shared diff --git a/CHANGELOG.md b/CHANGELOG.md index 401c5b03a..92c97f34d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log ## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A) +- (Feature) Extract Scheduler API ## [1.2.38](https://github.com/arangodb/kube-arangodb/tree/1.2.38) (2024-02-22) - (Feature) Extract GRPC Server diff --git a/Makefile b/Makefile index 95bf8f510..2e3b4f33d 100644 --- a/Makefile +++ b/Makefile @@ -431,14 +431,14 @@ update-generated: "client lister informer deepcopy" \ "github.com/arangodb/kube-arangodb/pkg/generated" \ "github.com/arangodb/kube-arangodb/pkg/apis" \ - "deployment:v1 replication:v1 storage:v1alpha backup:v1 deployment:v2alpha1 replication:v2alpha1 apps:v1 ml:v1alpha1" \ + "deployment:v1 replication:v1 storage:v1alpha backup:v1 deployment:v2alpha1 replication:v2alpha1 apps:v1 ml:v1alpha1 scheduler:v1alpha1" \ --go-header-file "./tools/codegen/boilerplate.go.txt" \ $(VERIFYARGS) GOPATH=$(GOBUILDDIR) $(VENDORDIR)/k8s.io/code-generator/generate-groups.sh \ "deepcopy" \ "github.com/arangodb/kube-arangodb/pkg/generated" \ "github.com/arangodb/kube-arangodb/pkg/apis" \ - "shared:v1" \ + "shared:v1 scheduler:v1alpha1/container scheduler:v1alpha1/container/resources scheduler:v1alpha1/pod scheduler:v1alpha1/pod/resources" \ --go-header-file "./tools/codegen/boilerplate.go.txt" \ $(VERIFYARGS) diff --git a/docs/api/ArangoMLExtension.V1Alpha1.md b/docs/api/ArangoMLExtension.V1Alpha1.md index a27c513ad..462427e1b 100644 --- a/docs/api/ArangoMLExtension.V1Alpha1.md +++ b/docs/api/ArangoMLExtension.V1Alpha1.md @@ -10,7 +10,7 @@ title: ArangoMLExtension V1Alpha1 ### .spec.deployment.affinity -Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L37) +Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L41) Affinity defines scheduling constraints for workload @@ -21,7 +21,7 @@ Links: ### .spec.deployment.hostIPC -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L33) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L39) HostIPC defines to use the host's ipc namespace. @@ -31,7 +31,7 @@ Default Value: `false` ### .spec.deployment.hostNetwork -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L27) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L33) HostNetwork requests Host network for this pod. Use the host's network namespace. If this option is set, the ports that will be used must be specified. @@ -42,7 +42,7 @@ Default Value: `false` ### .spec.deployment.hostPID -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L30) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L36) HostPID define to use the host's pid namespace. @@ -52,7 +52,7 @@ Default Value: `false` ### .spec.deployment.nodeSelector -Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L32) +Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L36) NodeSelector is a selector that must be true for the workload to fit on a node. @@ -63,7 +63,7 @@ Links: ### .spec.deployment.podSecurityContext -Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/security_pod.go#L29) +Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/security.go#L31) PodSecurityContext holds pod-level security attributes and common container settings. @@ -74,7 +74,7 @@ Links: ### .spec.deployment.prediction.env -Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L33) +Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L33) Env keeps the information about environment variables provided to the container @@ -85,7 +85,7 @@ Links: ### .spec.deployment.prediction.envFrom -Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L38) +Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L38) EnvFrom keeps the information about environment variable sources provided to the container @@ -106,41 +106,41 @@ Default Value: `false` ### .spec.deployment.prediction.image -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L31) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L34) Image define image details *** -### .spec.deployment.prediction.port +### .spec.deployment.prediction.imagePullPolicy -Type: `integer` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/ml/v1alpha1/extension_spec_deployment_component.go#L34) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L38) -Port defines on which port the container will be listening for connections +ImagePullPolicy define Image pull policy -*** +Default Value: `IfNotPresent` -### .spec.deployment.prediction.pullPolicy +*** -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L35) +### .spec.deployment.prediction.imagePullSecrets -PullPolicy define Image pull policy +Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L41) -Default Value: `IfNotPresent` +ImagePullSecrets define Secrets used to pull Image from registry *** -### .spec.deployment.prediction.pullSecrets +### .spec.deployment.prediction.port -Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L38) +Type: `integer` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/ml/v1alpha1/extension_spec_deployment_component.go#L34) -PullSecrets define Secrets used to pull Image from registry +Port defines on which port the container will be listening for connections *** ### .spec.deployment.prediction.resources -Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/resources.go#L34) +Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/resources.go#L34) Resources holds resource requests & limits for container @@ -151,7 +151,7 @@ Links: ### .spec.deployment.prediction.securityContext -Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/security_container.go#L29) +Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/security.go#L31) PodSecurityContext holds pod-level security attributes and common container settings. @@ -162,7 +162,7 @@ Links: ### .spec.deployment.project.env -Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L33) +Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L33) Env keeps the information about environment variables provided to the container @@ -173,7 +173,7 @@ Links: ### .spec.deployment.project.envFrom -Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L38) +Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L38) EnvFrom keeps the information about environment variable sources provided to the container @@ -194,41 +194,41 @@ Default Value: `false` ### .spec.deployment.project.image -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L31) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L34) Image define image details *** -### .spec.deployment.project.port +### .spec.deployment.project.imagePullPolicy -Type: `integer` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/ml/v1alpha1/extension_spec_deployment_component.go#L34) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L38) -Port defines on which port the container will be listening for connections +ImagePullPolicy define Image pull policy -*** +Default Value: `IfNotPresent` -### .spec.deployment.project.pullPolicy +*** -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L35) +### .spec.deployment.project.imagePullSecrets -PullPolicy define Image pull policy +Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L41) -Default Value: `IfNotPresent` +ImagePullSecrets define Secrets used to pull Image from registry *** -### .spec.deployment.project.pullSecrets +### .spec.deployment.project.port -Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L38) +Type: `integer` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/ml/v1alpha1/extension_spec_deployment_component.go#L34) -PullSecrets define Secrets used to pull Image from registry +Port defines on which port the container will be listening for connections *** ### .spec.deployment.project.resources -Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/resources.go#L34) +Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/resources.go#L34) Resources holds resource requests & limits for container @@ -239,7 +239,7 @@ Links: ### .spec.deployment.project.securityContext -Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/security_container.go#L29) +Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/security.go#L31) PodSecurityContext holds pod-level security attributes and common container settings. @@ -260,7 +260,7 @@ Default Value: `1` ### .spec.deployment.schedulerName -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L47) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L51) SchedulerName specifies, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler. @@ -288,7 +288,7 @@ Possible Values: ### .spec.deployment.shareProcessNamespace -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L39) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L45) ShareProcessNamespace defines to share a single process namespace between all of the containers in a pod. When this is set containers will be able to view and signal processes from other containers @@ -301,7 +301,7 @@ Default Value: `false` ### .spec.deployment.tolerations -Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L42) +Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L46) Tolerations defines tolerations @@ -312,7 +312,7 @@ Links: ### .spec.deployment.training.env -Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L33) +Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L33) Env keeps the information about environment variables provided to the container @@ -323,7 +323,7 @@ Links: ### .spec.deployment.training.envFrom -Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L38) +Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L38) EnvFrom keeps the information about environment variable sources provided to the container @@ -344,41 +344,41 @@ Default Value: `false` ### .spec.deployment.training.image -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L31) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L34) Image define image details *** -### .spec.deployment.training.port +### .spec.deployment.training.imagePullPolicy -Type: `integer` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/ml/v1alpha1/extension_spec_deployment_component.go#L34) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L38) -Port defines on which port the container will be listening for connections +ImagePullPolicy define Image pull policy -*** +Default Value: `IfNotPresent` -### .spec.deployment.training.pullPolicy +*** -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L35) +### .spec.deployment.training.imagePullSecrets -PullPolicy define Image pull policy +Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L41) -Default Value: `IfNotPresent` +ImagePullSecrets define Secrets used to pull Image from registry *** -### .spec.deployment.training.pullSecrets +### .spec.deployment.training.port -Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L38) +Type: `integer` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/ml/v1alpha1/extension_spec_deployment_component.go#L34) -PullSecrets define Secrets used to pull Image from registry +Port defines on which port the container will be listening for connections *** ### .spec.deployment.training.resources -Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/resources.go#L34) +Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/resources.go#L34) Resources holds resource requests & limits for container @@ -389,7 +389,7 @@ Links: ### .spec.deployment.training.securityContext -Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/security_container.go#L29) +Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/security.go#L31) PodSecurityContext holds pod-level security attributes and common container settings. @@ -400,15 +400,33 @@ Links: ### .spec.image -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L31) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L34) Image define image details *** +### .spec.imagePullPolicy + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L38) + +ImagePullPolicy define Image pull policy + +Default Value: `IfNotPresent` + +*** + +### .spec.imagePullSecrets + +Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L41) + +ImagePullSecrets define Secrets used to pull Image from registry + +*** + ### .spec.init.affinity -Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L37) +Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L41) Affinity defines scheduling constraints for workload @@ -419,7 +437,7 @@ Links: ### .spec.init.env -Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L33) +Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L33) Env keeps the information about environment variables provided to the container @@ -430,7 +448,7 @@ Links: ### .spec.init.envFrom -Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L38) +Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L38) EnvFrom keeps the information about environment variable sources provided to the container @@ -441,7 +459,7 @@ Links: ### .spec.init.hostIPC -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L33) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L39) HostIPC defines to use the host's ipc namespace. @@ -451,7 +469,7 @@ Default Value: `false` ### .spec.init.hostNetwork -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L27) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L33) HostNetwork requests Host network for this pod. Use the host's network namespace. If this option is set, the ports that will be used must be specified. @@ -462,7 +480,7 @@ Default Value: `false` ### .spec.init.hostPID -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L30) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L36) HostPID define to use the host's pid namespace. @@ -472,55 +490,55 @@ Default Value: `false` ### .spec.init.image -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L31) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L34) Image define image details *** -### .spec.init.nodeSelector +### .spec.init.imagePullPolicy -Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L32) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L38) -NodeSelector is a selector that must be true for the workload to fit on a node. +ImagePullPolicy define Image pull policy -Links: -* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) +Default Value: `IfNotPresent` *** -### .spec.init.podSecurityContext +### .spec.init.imagePullSecrets -Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/security_pod.go#L29) +Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L41) -PodSecurityContext holds pod-level security attributes and common container settings. - -Links: -* [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) +ImagePullSecrets define Secrets used to pull Image from registry *** -### .spec.init.pullPolicy +### .spec.init.nodeSelector -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L35) +Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L36) -PullPolicy define Image pull policy +NodeSelector is a selector that must be true for the workload to fit on a node. -Default Value: `IfNotPresent` +Links: +* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) *** -### .spec.init.pullSecrets +### .spec.init.podSecurityContext + +Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/security.go#L31) -Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L38) +PodSecurityContext holds pod-level security attributes and common container settings. -PullSecrets define Secrets used to pull Image from registry +Links: +* [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) *** ### .spec.init.resources -Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/resources.go#L34) +Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/resources.go#L34) Resources holds resource requests & limits for container @@ -531,7 +549,7 @@ Links: ### .spec.init.schedulerName -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L47) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L51) SchedulerName specifies, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler. @@ -542,7 +560,7 @@ Default Value: `""` ### .spec.init.securityContext -Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/security_container.go#L29) +Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/security.go#L31) PodSecurityContext holds pod-level security attributes and common container settings. @@ -553,7 +571,7 @@ Links: ### .spec.init.shareProcessNamespace -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L39) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L45) ShareProcessNamespace defines to share a single process namespace between all of the containers in a pod. When this is set containers will be able to view and signal processes from other containers @@ -566,7 +584,7 @@ Default Value: `false` ### .spec.init.tolerations -Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L42) +Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L46) Tolerations defines tolerations @@ -577,7 +595,7 @@ Links: ### .spec.jobsTemplates.featurization.cpu.affinity -Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L37) +Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L41) Affinity defines scheduling constraints for workload @@ -588,7 +606,7 @@ Links: ### .spec.jobsTemplates.featurization.cpu.env -Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L33) +Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L33) Env keeps the information about environment variables provided to the container @@ -599,7 +617,7 @@ Links: ### .spec.jobsTemplates.featurization.cpu.envFrom -Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L38) +Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L38) EnvFrom keeps the information about environment variable sources provided to the container @@ -610,7 +628,7 @@ Links: ### .spec.jobsTemplates.featurization.cpu.hostIPC -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L33) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L39) HostIPC defines to use the host's ipc namespace. @@ -620,7 +638,7 @@ Default Value: `false` ### .spec.jobsTemplates.featurization.cpu.hostNetwork -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L27) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L33) HostNetwork requests Host network for this pod. Use the host's network namespace. If this option is set, the ports that will be used must be specified. @@ -631,7 +649,7 @@ Default Value: `false` ### .spec.jobsTemplates.featurization.cpu.hostPID -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L30) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L36) HostPID define to use the host's pid namespace. @@ -641,55 +659,55 @@ Default Value: `false` ### .spec.jobsTemplates.featurization.cpu.image -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L31) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L34) Image define image details *** -### .spec.jobsTemplates.featurization.cpu.nodeSelector +### .spec.jobsTemplates.featurization.cpu.imagePullPolicy -Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L32) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L38) -NodeSelector is a selector that must be true for the workload to fit on a node. +ImagePullPolicy define Image pull policy -Links: -* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) +Default Value: `IfNotPresent` *** -### .spec.jobsTemplates.featurization.cpu.podSecurityContext - -Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/security_pod.go#L29) +### .spec.jobsTemplates.featurization.cpu.imagePullSecrets -PodSecurityContext holds pod-level security attributes and common container settings. +Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L41) -Links: -* [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) +ImagePullSecrets define Secrets used to pull Image from registry *** -### .spec.jobsTemplates.featurization.cpu.pullPolicy +### .spec.jobsTemplates.featurization.cpu.nodeSelector -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L35) +Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L36) -PullPolicy define Image pull policy +NodeSelector is a selector that must be true for the workload to fit on a node. -Default Value: `IfNotPresent` +Links: +* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) *** -### .spec.jobsTemplates.featurization.cpu.pullSecrets +### .spec.jobsTemplates.featurization.cpu.podSecurityContext + +Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/security.go#L31) -Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L38) +PodSecurityContext holds pod-level security attributes and common container settings. -PullSecrets define Secrets used to pull Image from registry +Links: +* [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) *** ### .spec.jobsTemplates.featurization.cpu.resources -Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/resources.go#L34) +Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/resources.go#L34) Resources holds resource requests & limits for container @@ -700,7 +718,7 @@ Links: ### .spec.jobsTemplates.featurization.cpu.schedulerName -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L47) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L51) SchedulerName specifies, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler. @@ -711,7 +729,7 @@ Default Value: `""` ### .spec.jobsTemplates.featurization.cpu.securityContext -Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/security_container.go#L29) +Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/security.go#L31) PodSecurityContext holds pod-level security attributes and common container settings. @@ -722,7 +740,7 @@ Links: ### .spec.jobsTemplates.featurization.cpu.shareProcessNamespace -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L39) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L45) ShareProcessNamespace defines to share a single process namespace between all of the containers in a pod. When this is set containers will be able to view and signal processes from other containers @@ -735,7 +753,7 @@ Default Value: `false` ### .spec.jobsTemplates.featurization.cpu.tolerations -Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L42) +Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L46) Tolerations defines tolerations @@ -746,7 +764,7 @@ Links: ### .spec.jobsTemplates.featurization.gpu.affinity -Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L37) +Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L41) Affinity defines scheduling constraints for workload @@ -757,7 +775,7 @@ Links: ### .spec.jobsTemplates.featurization.gpu.env -Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L33) +Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L33) Env keeps the information about environment variables provided to the container @@ -768,7 +786,7 @@ Links: ### .spec.jobsTemplates.featurization.gpu.envFrom -Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L38) +Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L38) EnvFrom keeps the information about environment variable sources provided to the container @@ -779,7 +797,7 @@ Links: ### .spec.jobsTemplates.featurization.gpu.hostIPC -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L33) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L39) HostIPC defines to use the host's ipc namespace. @@ -789,7 +807,7 @@ Default Value: `false` ### .spec.jobsTemplates.featurization.gpu.hostNetwork -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L27) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L33) HostNetwork requests Host network for this pod. Use the host's network namespace. If this option is set, the ports that will be used must be specified. @@ -800,7 +818,7 @@ Default Value: `false` ### .spec.jobsTemplates.featurization.gpu.hostPID -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L30) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L36) HostPID define to use the host's pid namespace. @@ -810,55 +828,55 @@ Default Value: `false` ### .spec.jobsTemplates.featurization.gpu.image -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L31) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L34) Image define image details *** -### .spec.jobsTemplates.featurization.gpu.nodeSelector +### .spec.jobsTemplates.featurization.gpu.imagePullPolicy -Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L32) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L38) -NodeSelector is a selector that must be true for the workload to fit on a node. +ImagePullPolicy define Image pull policy -Links: -* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) +Default Value: `IfNotPresent` *** -### .spec.jobsTemplates.featurization.gpu.podSecurityContext - -Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/security_pod.go#L29) +### .spec.jobsTemplates.featurization.gpu.imagePullSecrets -PodSecurityContext holds pod-level security attributes and common container settings. +Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L41) -Links: -* [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) +ImagePullSecrets define Secrets used to pull Image from registry *** -### .spec.jobsTemplates.featurization.gpu.pullPolicy +### .spec.jobsTemplates.featurization.gpu.nodeSelector -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L35) +Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L36) -PullPolicy define Image pull policy +NodeSelector is a selector that must be true for the workload to fit on a node. -Default Value: `IfNotPresent` +Links: +* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) *** -### .spec.jobsTemplates.featurization.gpu.pullSecrets +### .spec.jobsTemplates.featurization.gpu.podSecurityContext -Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L38) +Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/security.go#L31) -PullSecrets define Secrets used to pull Image from registry +PodSecurityContext holds pod-level security attributes and common container settings. + +Links: +* [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) *** ### .spec.jobsTemplates.featurization.gpu.resources -Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/resources.go#L34) +Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/resources.go#L34) Resources holds resource requests & limits for container @@ -869,7 +887,7 @@ Links: ### .spec.jobsTemplates.featurization.gpu.schedulerName -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L47) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L51) SchedulerName specifies, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler. @@ -880,7 +898,7 @@ Default Value: `""` ### .spec.jobsTemplates.featurization.gpu.securityContext -Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/security_container.go#L29) +Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/security.go#L31) PodSecurityContext holds pod-level security attributes and common container settings. @@ -891,7 +909,7 @@ Links: ### .spec.jobsTemplates.featurization.gpu.shareProcessNamespace -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L39) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L45) ShareProcessNamespace defines to share a single process namespace between all of the containers in a pod. When this is set containers will be able to view and signal processes from other containers @@ -904,7 +922,7 @@ Default Value: `false` ### .spec.jobsTemplates.featurization.gpu.tolerations -Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L42) +Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L46) Tolerations defines tolerations @@ -915,7 +933,7 @@ Links: ### .spec.jobsTemplates.prediction.cpu.affinity -Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L37) +Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L41) Affinity defines scheduling constraints for workload @@ -926,7 +944,7 @@ Links: ### .spec.jobsTemplates.prediction.cpu.env -Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L33) +Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L33) Env keeps the information about environment variables provided to the container @@ -937,7 +955,7 @@ Links: ### .spec.jobsTemplates.prediction.cpu.envFrom -Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L38) +Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L38) EnvFrom keeps the information about environment variable sources provided to the container @@ -948,7 +966,7 @@ Links: ### .spec.jobsTemplates.prediction.cpu.hostIPC -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L33) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L39) HostIPC defines to use the host's ipc namespace. @@ -958,7 +976,7 @@ Default Value: `false` ### .spec.jobsTemplates.prediction.cpu.hostNetwork -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L27) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L33) HostNetwork requests Host network for this pod. Use the host's network namespace. If this option is set, the ports that will be used must be specified. @@ -969,7 +987,7 @@ Default Value: `false` ### .spec.jobsTemplates.prediction.cpu.hostPID -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L30) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L36) HostPID define to use the host's pid namespace. @@ -979,55 +997,55 @@ Default Value: `false` ### .spec.jobsTemplates.prediction.cpu.image -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L31) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L34) Image define image details *** -### .spec.jobsTemplates.prediction.cpu.nodeSelector +### .spec.jobsTemplates.prediction.cpu.imagePullPolicy -Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L32) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L38) -NodeSelector is a selector that must be true for the workload to fit on a node. +ImagePullPolicy define Image pull policy -Links: -* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) +Default Value: `IfNotPresent` *** -### .spec.jobsTemplates.prediction.cpu.podSecurityContext +### .spec.jobsTemplates.prediction.cpu.imagePullSecrets -Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/security_pod.go#L29) +Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L41) -PodSecurityContext holds pod-level security attributes and common container settings. - -Links: -* [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) +ImagePullSecrets define Secrets used to pull Image from registry *** -### .spec.jobsTemplates.prediction.cpu.pullPolicy +### .spec.jobsTemplates.prediction.cpu.nodeSelector -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L35) +Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L36) -PullPolicy define Image pull policy +NodeSelector is a selector that must be true for the workload to fit on a node. -Default Value: `IfNotPresent` +Links: +* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) *** -### .spec.jobsTemplates.prediction.cpu.pullSecrets +### .spec.jobsTemplates.prediction.cpu.podSecurityContext + +Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/security.go#L31) -Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L38) +PodSecurityContext holds pod-level security attributes and common container settings. -PullSecrets define Secrets used to pull Image from registry +Links: +* [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) *** ### .spec.jobsTemplates.prediction.cpu.resources -Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/resources.go#L34) +Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/resources.go#L34) Resources holds resource requests & limits for container @@ -1038,7 +1056,7 @@ Links: ### .spec.jobsTemplates.prediction.cpu.schedulerName -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L47) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L51) SchedulerName specifies, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler. @@ -1049,7 +1067,7 @@ Default Value: `""` ### .spec.jobsTemplates.prediction.cpu.securityContext -Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/security_container.go#L29) +Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/security.go#L31) PodSecurityContext holds pod-level security attributes and common container settings. @@ -1060,7 +1078,7 @@ Links: ### .spec.jobsTemplates.prediction.cpu.shareProcessNamespace -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L39) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L45) ShareProcessNamespace defines to share a single process namespace between all of the containers in a pod. When this is set containers will be able to view and signal processes from other containers @@ -1073,7 +1091,7 @@ Default Value: `false` ### .spec.jobsTemplates.prediction.cpu.tolerations -Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L42) +Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L46) Tolerations defines tolerations @@ -1084,7 +1102,7 @@ Links: ### .spec.jobsTemplates.prediction.gpu.affinity -Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L37) +Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L41) Affinity defines scheduling constraints for workload @@ -1095,7 +1113,7 @@ Links: ### .spec.jobsTemplates.prediction.gpu.env -Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L33) +Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L33) Env keeps the information about environment variables provided to the container @@ -1106,7 +1124,7 @@ Links: ### .spec.jobsTemplates.prediction.gpu.envFrom -Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L38) +Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L38) EnvFrom keeps the information about environment variable sources provided to the container @@ -1117,7 +1135,7 @@ Links: ### .spec.jobsTemplates.prediction.gpu.hostIPC -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L33) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L39) HostIPC defines to use the host's ipc namespace. @@ -1127,7 +1145,7 @@ Default Value: `false` ### .spec.jobsTemplates.prediction.gpu.hostNetwork -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L27) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L33) HostNetwork requests Host network for this pod. Use the host's network namespace. If this option is set, the ports that will be used must be specified. @@ -1138,7 +1156,7 @@ Default Value: `false` ### .spec.jobsTemplates.prediction.gpu.hostPID -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L30) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L36) HostPID define to use the host's pid namespace. @@ -1148,55 +1166,55 @@ Default Value: `false` ### .spec.jobsTemplates.prediction.gpu.image -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L31) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L34) Image define image details *** -### .spec.jobsTemplates.prediction.gpu.nodeSelector +### .spec.jobsTemplates.prediction.gpu.imagePullPolicy -Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L32) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L38) -NodeSelector is a selector that must be true for the workload to fit on a node. +ImagePullPolicy define Image pull policy -Links: -* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) +Default Value: `IfNotPresent` *** -### .spec.jobsTemplates.prediction.gpu.podSecurityContext - -Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/security_pod.go#L29) +### .spec.jobsTemplates.prediction.gpu.imagePullSecrets -PodSecurityContext holds pod-level security attributes and common container settings. +Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L41) -Links: -* [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) +ImagePullSecrets define Secrets used to pull Image from registry *** -### .spec.jobsTemplates.prediction.gpu.pullPolicy +### .spec.jobsTemplates.prediction.gpu.nodeSelector -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L35) +Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L36) -PullPolicy define Image pull policy +NodeSelector is a selector that must be true for the workload to fit on a node. -Default Value: `IfNotPresent` +Links: +* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) *** -### .spec.jobsTemplates.prediction.gpu.pullSecrets +### .spec.jobsTemplates.prediction.gpu.podSecurityContext + +Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/security.go#L31) -Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L38) +PodSecurityContext holds pod-level security attributes and common container settings. -PullSecrets define Secrets used to pull Image from registry +Links: +* [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) *** ### .spec.jobsTemplates.prediction.gpu.resources -Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/resources.go#L34) +Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/resources.go#L34) Resources holds resource requests & limits for container @@ -1207,7 +1225,7 @@ Links: ### .spec.jobsTemplates.prediction.gpu.schedulerName -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L47) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L51) SchedulerName specifies, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler. @@ -1218,7 +1236,7 @@ Default Value: `""` ### .spec.jobsTemplates.prediction.gpu.securityContext -Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/security_container.go#L29) +Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/security.go#L31) PodSecurityContext holds pod-level security attributes and common container settings. @@ -1229,7 +1247,7 @@ Links: ### .spec.jobsTemplates.prediction.gpu.shareProcessNamespace -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L39) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L45) ShareProcessNamespace defines to share a single process namespace between all of the containers in a pod. When this is set containers will be able to view and signal processes from other containers @@ -1242,7 +1260,7 @@ Default Value: `false` ### .spec.jobsTemplates.prediction.gpu.tolerations -Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L42) +Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L46) Tolerations defines tolerations @@ -1253,7 +1271,7 @@ Links: ### .spec.jobsTemplates.training.cpu.affinity -Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L37) +Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L41) Affinity defines scheduling constraints for workload @@ -1264,7 +1282,7 @@ Links: ### .spec.jobsTemplates.training.cpu.env -Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L33) +Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L33) Env keeps the information about environment variables provided to the container @@ -1275,7 +1293,7 @@ Links: ### .spec.jobsTemplates.training.cpu.envFrom -Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L38) +Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L38) EnvFrom keeps the information about environment variable sources provided to the container @@ -1286,7 +1304,7 @@ Links: ### .spec.jobsTemplates.training.cpu.hostIPC -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L33) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L39) HostIPC defines to use the host's ipc namespace. @@ -1296,7 +1314,7 @@ Default Value: `false` ### .spec.jobsTemplates.training.cpu.hostNetwork -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L27) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L33) HostNetwork requests Host network for this pod. Use the host's network namespace. If this option is set, the ports that will be used must be specified. @@ -1307,7 +1325,7 @@ Default Value: `false` ### .spec.jobsTemplates.training.cpu.hostPID -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L30) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L36) HostPID define to use the host's pid namespace. @@ -1317,55 +1335,55 @@ Default Value: `false` ### .spec.jobsTemplates.training.cpu.image -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L31) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L34) Image define image details *** -### .spec.jobsTemplates.training.cpu.nodeSelector +### .spec.jobsTemplates.training.cpu.imagePullPolicy -Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L32) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L38) -NodeSelector is a selector that must be true for the workload to fit on a node. +ImagePullPolicy define Image pull policy -Links: -* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) +Default Value: `IfNotPresent` *** -### .spec.jobsTemplates.training.cpu.podSecurityContext - -Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/security_pod.go#L29) +### .spec.jobsTemplates.training.cpu.imagePullSecrets -PodSecurityContext holds pod-level security attributes and common container settings. +Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L41) -Links: -* [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) +ImagePullSecrets define Secrets used to pull Image from registry *** -### .spec.jobsTemplates.training.cpu.pullPolicy +### .spec.jobsTemplates.training.cpu.nodeSelector -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L35) +Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L36) -PullPolicy define Image pull policy +NodeSelector is a selector that must be true for the workload to fit on a node. -Default Value: `IfNotPresent` +Links: +* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) *** -### .spec.jobsTemplates.training.cpu.pullSecrets +### .spec.jobsTemplates.training.cpu.podSecurityContext + +Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/security.go#L31) -Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L38) +PodSecurityContext holds pod-level security attributes and common container settings. -PullSecrets define Secrets used to pull Image from registry +Links: +* [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) *** ### .spec.jobsTemplates.training.cpu.resources -Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/resources.go#L34) +Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/resources.go#L34) Resources holds resource requests & limits for container @@ -1376,7 +1394,7 @@ Links: ### .spec.jobsTemplates.training.cpu.schedulerName -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L47) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L51) SchedulerName specifies, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler. @@ -1387,7 +1405,7 @@ Default Value: `""` ### .spec.jobsTemplates.training.cpu.securityContext -Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/security_container.go#L29) +Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/security.go#L31) PodSecurityContext holds pod-level security attributes and common container settings. @@ -1398,7 +1416,7 @@ Links: ### .spec.jobsTemplates.training.cpu.shareProcessNamespace -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L39) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L45) ShareProcessNamespace defines to share a single process namespace between all of the containers in a pod. When this is set containers will be able to view and signal processes from other containers @@ -1411,7 +1429,7 @@ Default Value: `false` ### .spec.jobsTemplates.training.cpu.tolerations -Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L42) +Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L46) Tolerations defines tolerations @@ -1422,7 +1440,7 @@ Links: ### .spec.jobsTemplates.training.gpu.affinity -Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L37) +Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L41) Affinity defines scheduling constraints for workload @@ -1433,7 +1451,7 @@ Links: ### .spec.jobsTemplates.training.gpu.env -Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L33) +Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L33) Env keeps the information about environment variables provided to the container @@ -1444,7 +1462,7 @@ Links: ### .spec.jobsTemplates.training.gpu.envFrom -Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L38) +Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L38) EnvFrom keeps the information about environment variable sources provided to the container @@ -1455,7 +1473,7 @@ Links: ### .spec.jobsTemplates.training.gpu.hostIPC -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L33) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L39) HostIPC defines to use the host's ipc namespace. @@ -1465,7 +1483,7 @@ Default Value: `false` ### .spec.jobsTemplates.training.gpu.hostNetwork -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L27) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L33) HostNetwork requests Host network for this pod. Use the host's network namespace. If this option is set, the ports that will be used must be specified. @@ -1476,7 +1494,7 @@ Default Value: `false` ### .spec.jobsTemplates.training.gpu.hostPID -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L30) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L36) HostPID define to use the host's pid namespace. @@ -1486,55 +1504,55 @@ Default Value: `false` ### .spec.jobsTemplates.training.gpu.image -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L31) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L34) Image define image details *** -### .spec.jobsTemplates.training.gpu.nodeSelector +### .spec.jobsTemplates.training.gpu.imagePullPolicy -Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L32) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L38) -NodeSelector is a selector that must be true for the workload to fit on a node. +ImagePullPolicy define Image pull policy -Links: -* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) +Default Value: `IfNotPresent` *** -### .spec.jobsTemplates.training.gpu.podSecurityContext - -Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/security_pod.go#L29) +### .spec.jobsTemplates.training.gpu.imagePullSecrets -PodSecurityContext holds pod-level security attributes and common container settings. +Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L41) -Links: -* [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) +ImagePullSecrets define Secrets used to pull Image from registry *** -### .spec.jobsTemplates.training.gpu.pullPolicy +### .spec.jobsTemplates.training.gpu.nodeSelector -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L35) +Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L36) -PullPolicy define Image pull policy +NodeSelector is a selector that must be true for the workload to fit on a node. -Default Value: `IfNotPresent` +Links: +* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) *** -### .spec.jobsTemplates.training.gpu.pullSecrets +### .spec.jobsTemplates.training.gpu.podSecurityContext + +Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/security.go#L31) -Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L38) +PodSecurityContext holds pod-level security attributes and common container settings. -PullSecrets define Secrets used to pull Image from registry +Links: +* [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) *** ### .spec.jobsTemplates.training.gpu.resources -Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/resources.go#L34) +Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/resources.go#L34) Resources holds resource requests & limits for container @@ -1545,7 +1563,7 @@ Links: ### .spec.jobsTemplates.training.gpu.schedulerName -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L47) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L51) SchedulerName specifies, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler. @@ -1556,7 +1574,7 @@ Default Value: `""` ### .spec.jobsTemplates.training.gpu.securityContext -Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/security_container.go#L29) +Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/security.go#L31) PodSecurityContext holds pod-level security attributes and common container settings. @@ -1567,7 +1585,7 @@ Links: ### .spec.jobsTemplates.training.gpu.shareProcessNamespace -Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/container_namespace.go#L39) +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go#L45) ShareProcessNamespace defines to share a single process namespace between all of the containers in a pod. When this is set containers will be able to view and signal processes from other containers @@ -1580,7 +1598,7 @@ Default Value: `false` ### .spec.jobsTemplates.training.gpu.tolerations -Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/scheduling.go#L42) +Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go#L46) Tolerations defines tolerations @@ -1609,24 +1627,6 @@ Default Value: `arangopipe` *** -### .spec.pullPolicy - -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L35) - -PullPolicy define Image pull policy - -Default Value: `IfNotPresent` - -*** - -### .spec.pullSecrets - -Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L38) - -PullSecrets define Secrets used to pull Image from registry - -*** - ### .spec.storage.name Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/object.go#L46) diff --git a/docs/api/ArangoMLStorage.V1Alpha1.md b/docs/api/ArangoMLStorage.V1Alpha1.md index 3962e6199..8ec2b6e09 100644 --- a/docs/api/ArangoMLStorage.V1Alpha1.md +++ b/docs/api/ArangoMLStorage.V1Alpha1.md @@ -116,7 +116,7 @@ Default Value: `9202` ### .spec.mode.sidecar.env -Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L33) +Type: `core.EnvVar` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L33) Env keeps the information about environment variables provided to the container @@ -127,7 +127,7 @@ Links: ### .spec.mode.sidecar.envFrom -Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/envs.go#L38) +Type: `core.EnvFromSource` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/environments.go#L38) EnvFrom keeps the information about environment variable sources provided to the container @@ -138,43 +138,43 @@ Links: ### .spec.mode.sidecar.image -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L31) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L34) Image define image details *** -### .spec.mode.sidecar.listenPort +### .spec.mode.sidecar.imagePullPolicy -Type: `integer` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/ml/v1alpha1/storage_spec_mode_sidecar.go#L32) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L38) -ListenPort defines on which port the sidecar container will be listening for connections +ImagePullPolicy define Image pull policy -Default Value: `9201` +Default Value: `IfNotPresent` *** -### .spec.mode.sidecar.pullPolicy - -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L35) +### .spec.mode.sidecar.imagePullSecrets -PullPolicy define Image pull policy +Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/image.go#L41) -Default Value: `IfNotPresent` +ImagePullSecrets define Secrets used to pull Image from registry *** -### .spec.mode.sidecar.pullSecrets +### .spec.mode.sidecar.listenPort + +Type: `integer` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/ml/v1alpha1/storage_spec_mode_sidecar.go#L32) -Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/image.go#L38) +ListenPort defines on which port the sidecar container will be listening for connections -PullSecrets define Secrets used to pull Image from registry +Default Value: `9201` *** ### .spec.mode.sidecar.resources -Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/resources.go#L34) +Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/resources.go#L34) Resources holds resource requests & limits for container @@ -185,7 +185,7 @@ Links: ### .spec.mode.sidecar.securityContext -Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/shared/v1/security_container.go#L29) +Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.38/pkg/apis/scheduler/v1alpha1/container/resources/security.go#L31) PodSecurityContext holds pod-level security attributes and common container settings. diff --git a/internal/docs_test.go b/internal/docs_test.go index 6f51e20df..413a87dc6 100644 --- a/internal/docs_test.go +++ b/internal/docs_test.go @@ -137,72 +137,118 @@ func Test_GenerateAPIDocs(t *testing.T) { fset := token.NewFileSet() - sharedFields := parseSourceFiles(t, root, fset, fmt.Sprintf("%s/pkg/apis/shared/v1", root)) + type inputPackageTypes map[string]map[string]any + + type inputPackage struct { + Types inputPackageTypes + + Shared []string + } + + type inputPackages map[string]map[string]inputPackage // package path -> result doc file name -> name of the top-level field to be described -> field instance for reflection - input := map[string]map[string]map[string]interface{}{ - fmt.Sprintf("%s/pkg/apis/deployment/v1", root): { - "ArangoDeployment.V1": { - "Spec": deploymentApi.ArangoDeployment{}.Spec, - }, - "ArangoMember.V1": { - "Spec": deploymentApi.ArangoMember{}.Spec, + input := inputPackages{ + "deployment": map[string]inputPackage{ + "v1": { + Types: inputPackageTypes{ + "ArangoDeployment.V1": { + "Spec": deploymentApi.ArangoDeployment{}.Spec, + }, + "ArangoMember.V1": { + "Spec": deploymentApi.ArangoMember{}.Spec, + }, + }, }, }, - fmt.Sprintf("%s/pkg/apis/apps/v1", root): { - "ArangoJob.V1": { - "Spec": appsApi.ArangoJob{}.Spec, + "apps": map[string]inputPackage{ + "v1": { + Types: inputPackageTypes{ + "ArangoJob.V1": { + "Spec": appsApi.ArangoJob{}.Spec, + }, + }, }, }, - fmt.Sprintf("%s/pkg/apis/backup/v1", root): { - "ArangoBackup.V1": { - "Spec": backupApi.ArangoBackup{}.Spec, - "Status": backupApi.ArangoBackup{}.Status, - }, - "ArangoBackupPolicy.V1": { - "Spec": backupApi.ArangoBackupPolicy{}.Spec, - "Status": backupApi.ArangoBackupPolicy{}.Status, + "backup": map[string]inputPackage{ + "v1": { + Types: inputPackageTypes{ + "ArangoBackup.V1": { + "Spec": backupApi.ArangoBackup{}.Spec, + "Status": backupApi.ArangoBackup{}.Status, + }, + "ArangoBackupPolicy.V1": { + "Spec": backupApi.ArangoBackupPolicy{}.Spec, + "Status": backupApi.ArangoBackupPolicy{}.Status, + }, + }, }, }, - fmt.Sprintf("%s/pkg/apis/ml/v1alpha1", root): { - "ArangoMLExtension.V1Alpha1": { - "Spec": mlApi.ArangoMLExtension{}.Spec, - "Status": mlApi.ArangoMLExtension{}.Status, - }, - "ArangoMLStorage.V1Alpha1": { - "Spec": mlApi.ArangoMLStorage{}.Spec, - "Status": mlApi.ArangoMLStorage{}.Status, - }, - "ArangoMLCronJob.V1Alpha1": { - "Spec": mlApi.ArangoMLCronJob{}.Spec, - "Status": mlApi.ArangoMLCronJob{}.Status, - }, - "ArangoMLBatchJob.V1Alpha1": { - "Spec": mlApi.ArangoMLBatchJob{}.Spec, - "Status": mlApi.ArangoMLBatchJob{}.Status, + "ml": map[string]inputPackage{ + "v1alpha1": { + Types: inputPackageTypes{ + "ArangoMLExtension.V1Alpha1": { + "Spec": mlApi.ArangoMLExtension{}.Spec, + "Status": mlApi.ArangoMLExtension{}.Status, + }, + "ArangoMLStorage.V1Alpha1": { + "Spec": mlApi.ArangoMLStorage{}.Spec, + "Status": mlApi.ArangoMLStorage{}.Status, + }, + "ArangoMLCronJob.V1Alpha1": { + "Spec": mlApi.ArangoMLCronJob{}.Spec, + "Status": mlApi.ArangoMLCronJob{}.Status, + }, + "ArangoMLBatchJob.V1Alpha1": { + "Spec": mlApi.ArangoMLBatchJob{}.Spec, + "Status": mlApi.ArangoMLBatchJob{}.Status, + }, + }, + Shared: []string{ + "shared/v1", + "scheduler/v1alpha1", + "scheduler/v1alpha1/container", + "scheduler/v1alpha1/container/resources", + "scheduler/v1alpha1/pod", + "scheduler/v1alpha1/pod/resources", + }, }, }, - fmt.Sprintf("%s/pkg/apis/replication/v1", root): { - "ArangoDeploymentReplication.V1": { - "Spec": replicationApi.ArangoDeploymentReplication{}.Spec, + "replication": map[string]inputPackage{ + "v1": { + Types: inputPackageTypes{ + "ArangoDeploymentReplication.V1": { + "Spec": replicationApi.ArangoDeploymentReplication{}.Spec, + }, + }, }, }, - fmt.Sprintf("%s/pkg/apis/storage/v1alpha", root): { - "ArangoLocalStorage.V1Alpha": { - "Spec": storageApi.ArangoLocalStorage{}.Spec, + "storage": map[string]inputPackage{ + "v1alpha": { + Types: inputPackageTypes{ + "ArangoLocalStorage.V1Alpha": { + "Spec": storageApi.ArangoLocalStorage{}.Spec, + }, + }, }, }, } - for apiDir, docs := range input { - fields := parseSourceFiles(t, root, fset, apiDir) + for name, versions := range input { + for version, docs := range versions { + fields := parseSourceFiles(t, root, fset, path.Join(root, "pkg/apis", name, version)) - for n, f := range sharedFields { - require.NotContains(t, fields, n) - fields[n] = f - } + for _, p := range docs.Shared { + sharedFields := parseSourceFiles(t, root, fset, path.Join(root, "pkg/apis", p)) - generateDocs(t, docs, fields, fset) + for n, f := range sharedFields { + require.NotContains(t, fields, n) + fields[n] = f + } + } + + generateDocs(t, docs.Types, fields, fset) + } } } diff --git a/pkg/apis/ml/v1alpha1/extension_spec.go b/pkg/apis/ml/v1alpha1/extension_spec.go index 0ce6f8927..4722e198e 100644 --- a/pkg/apis/ml/v1alpha1/extension_spec.go +++ b/pkg/apis/ml/v1alpha1/extension_spec.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ package v1alpha1 import ( + schedulerContainerResourcesApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/container/resources" shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" sharedApi "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1" ) @@ -34,7 +35,7 @@ type ArangoMLExtensionSpec struct { Storage *sharedApi.Object `json:"storage,omitempty"` // Image defines default image used for the extension - *sharedApi.Image `json:",inline"` + *schedulerContainerResourcesApi.Image `json:",inline"` // ArangoMLExtensionTemplate define Init job specification Init *ArangoMLExtensionTemplate `json:"init,omitempty"` @@ -54,7 +55,7 @@ func (a *ArangoMLExtensionSpec) GetMetadataService() *ArangoMLExtensionSpecMetad return a.MetadataService } -func (a *ArangoMLExtensionSpec) GetImage() *sharedApi.Image { +func (a *ArangoMLExtensionSpec) GetImage() *schedulerContainerResourcesApi.Image { if a == nil || a.Image == nil { return nil } @@ -102,7 +103,7 @@ func (a *ArangoMLExtensionSpec) Validate() error { shared.PrefixResourceErrors("storage", shared.ValidateRequired(a.GetStorage(), func(obj sharedApi.Object) error { return obj.Validate() })), a.GetImage().Validate(), shared.PrefixResourceErrors("init", a.GetInit().Validate()), - shared.ValidateAnyNotNil(".image or .init.image needs to be specified", a.GetImage(), a.GetInit().GetContainerTemplate().GetImage()), + shared.ValidateAnyNotNil(".image or .init.image needs to be specified", a.GetImage(), a.GetInit().GetContainer().GetImage()), shared.PrefixResourceErrors("deployment", a.GetDeployment().Validate()), shared.PrefixResourceErrors("jobsTemplates", a.GetJobsTemplates().Validate()), )) diff --git a/pkg/apis/ml/v1alpha1/extension_spec_deployment.go b/pkg/apis/ml/v1alpha1/extension_spec_deployment.go index b06064bd4..fc6d7543f 100644 --- a/pkg/apis/ml/v1alpha1/extension_spec_deployment.go +++ b/pkg/apis/ml/v1alpha1/extension_spec_deployment.go @@ -21,8 +21,8 @@ package v1alpha1 import ( + schedulerPodApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/pod" shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" - sharedApi "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1" "github.com/arangodb/kube-arangodb/pkg/util" "github.com/arangodb/kube-arangodb/pkg/util/errors" ) @@ -58,8 +58,8 @@ type ArangoMLExtensionSpecDeployment struct { // Service defines how components will be exposed Service *ArangoMLExtensionSpecDeploymentService `json:"service,omitempty"` - // PodTemplate defines base template for pods - *sharedApi.PodTemplate + // Pod defines base template for pods + *schedulerPodApi.Pod // Prediction defines how Prediction workload will be deployed Prediction *ArangoMLExtensionSpecDeploymentComponent `json:"prediction,omitempty"` @@ -76,12 +76,12 @@ func (s *ArangoMLExtensionSpecDeployment) GetReplicas() int32 { return *s.Replicas } -func (s *ArangoMLExtensionSpecDeployment) GetPodTemplate() *sharedApi.PodTemplate { - if s == nil || s.PodTemplate == nil { +func (s *ArangoMLExtensionSpecDeployment) GetPodTemplate() *schedulerPodApi.Pod { + if s == nil || s.Pod == nil { return nil } - return s.PodTemplate + return s.Pod } func (s *ArangoMLExtensionSpecDeployment) GetPrediction() *ArangoMLExtensionSpecDeploymentComponent { diff --git a/pkg/apis/ml/v1alpha1/extension_spec_deployment_component.go b/pkg/apis/ml/v1alpha1/extension_spec_deployment_component.go index b706dc49d..3ab230967 100644 --- a/pkg/apis/ml/v1alpha1/extension_spec_deployment_component.go +++ b/pkg/apis/ml/v1alpha1/extension_spec_deployment_component.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -21,8 +21,8 @@ package v1alpha1 import ( + schedulerContainerApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/container" shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" - sharedApi "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1" ) type ArangoMLExtensionSpecDeploymentComponent struct { @@ -33,8 +33,8 @@ type ArangoMLExtensionSpecDeploymentComponent struct { // Port defines on which port the container will be listening for connections Port *int32 `json:"port,omitempty"` - // ContainerTemplate Keeps the information about Container configuration - *sharedApi.ContainerTemplate `json:",inline"` + // Container Keeps the information about Container configuration + *schedulerContainerApi.Container `json:",inline"` } func (s *ArangoMLExtensionSpecDeploymentComponent) GetGPU() bool { @@ -51,12 +51,12 @@ func (s *ArangoMLExtensionSpecDeploymentComponent) GetPort(def int32) int32 { return *s.Port } -func (s *ArangoMLExtensionSpecDeploymentComponent) GetContainerTemplate() *sharedApi.ContainerTemplate { - if s == nil || s.ContainerTemplate == nil { +func (s *ArangoMLExtensionSpecDeploymentComponent) GetContainer() *schedulerContainerApi.Container { + if s == nil || s.Container == nil { return nil } - return s.ContainerTemplate + return s.Container } func (s *ArangoMLExtensionSpecDeploymentComponent) Validate() error { @@ -67,7 +67,7 @@ func (s *ArangoMLExtensionSpecDeploymentComponent) Validate() error { var err []error err = append(err, - s.GetContainerTemplate().Validate(), + s.GetContainer().Validate(), ) return shared.WithErrors(err...) diff --git a/pkg/apis/ml/v1alpha1/extension_spec_job.go b/pkg/apis/ml/v1alpha1/extension_spec_job.go index b7b693441..15fda1bf6 100644 --- a/pkg/apis/ml/v1alpha1/extension_spec_job.go +++ b/pkg/apis/ml/v1alpha1/extension_spec_job.go @@ -21,8 +21,9 @@ package v1alpha1 import ( + schedulerContainerApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/container" + schedulerPodApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/pod" shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" - sharedApi "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1" ) type JobType string @@ -115,27 +116,27 @@ func (a *ArangoMLJobTemplates) Validate() error { } type ArangoMLExtensionTemplate struct { - // PodTemplate keeps the information about Pod configuration - *sharedApi.PodTemplate `json:",inline"` + // Pod keeps the information about Pod configuration + *schedulerPodApi.Pod `json:",inline"` - // ContainerTemplate Keeps the information about Container configuration - *sharedApi.ContainerTemplate `json:",inline"` + // Container Keeps the information about Container configuration + *schedulerContainerApi.Container `json:",inline"` } -func (a *ArangoMLExtensionTemplate) GetPodTemplate() *sharedApi.PodTemplate { - if a == nil { +func (a *ArangoMLExtensionTemplate) GetPodTemplate() *schedulerPodApi.Pod { + if a == nil || a.Pod == nil { return nil } - return a.PodTemplate + return a.Pod } -func (a *ArangoMLExtensionTemplate) GetContainerTemplate() *sharedApi.ContainerTemplate { - if a == nil { +func (a *ArangoMLExtensionTemplate) GetContainer() *schedulerContainerApi.Container { + if a == nil || a.Container == nil { return nil } - return a.ContainerTemplate + return a.Container } func (a *ArangoMLExtensionTemplate) Validate() error { @@ -145,6 +146,6 @@ func (a *ArangoMLExtensionTemplate) Validate() error { return shared.WithErrors( a.GetPodTemplate().Validate(), - a.GetContainerTemplate().Validate(), + a.GetContainer().Validate(), ) } diff --git a/pkg/apis/ml/v1alpha1/storage_spec_mode_sidecar.go b/pkg/apis/ml/v1alpha1/storage_spec_mode_sidecar.go index fe72eb704..81f00ebdf 100644 --- a/pkg/apis/ml/v1alpha1/storage_spec_mode_sidecar.go +++ b/pkg/apis/ml/v1alpha1/storage_spec_mode_sidecar.go @@ -21,8 +21,8 @@ package v1alpha1 import ( + schedulerContainerApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/container" shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" - sharedApi "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1" "github.com/arangodb/kube-arangodb/pkg/util/errors" ) @@ -35,16 +35,16 @@ type ArangoMLStorageSpecModeSidecar struct { // +doc/default: 9202 ControllerListenPort *uint16 `json:"controllerListenPort,omitempty"` - // ContainerTemplate Keeps the information about Container configuration - *sharedApi.ContainerTemplate `json:",inline"` + // Container Keeps the information about Container configuration + *schedulerContainerApi.Container `json:",inline"` } -func (s *ArangoMLStorageSpecModeSidecar) GetContainerTemplate() *sharedApi.ContainerTemplate { - if s == nil || s.ContainerTemplate == nil { +func (s *ArangoMLStorageSpecModeSidecar) GetContainer() *schedulerContainerApi.Container { + if s == nil || s.Container == nil { return nil } - return s.ContainerTemplate + return s.Container } func (s *ArangoMLStorageSpecModeSidecar) Validate() error { @@ -62,7 +62,7 @@ func (s *ArangoMLStorageSpecModeSidecar) Validate() error { err = append(err, shared.PrefixResourceErrors("controllerListenPort", errors.Errorf("must be positive"))) } - err = append(err, s.GetContainerTemplate().Validate()) + err = append(err, s.GetContainer().Validate()) return shared.WithErrors(err...) } diff --git a/pkg/apis/ml/v1alpha1/storage_spec_test.go b/pkg/apis/ml/v1alpha1/storage_spec_test.go index 78bbcb7d1..92dcde507 100644 --- a/pkg/apis/ml/v1alpha1/storage_spec_test.go +++ b/pkg/apis/ml/v1alpha1/storage_spec_test.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -27,6 +27,8 @@ import ( core "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" + schedulerContainerApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/container" + schedulerContainerResourcesApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/container/resources" sharedApi "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1" "github.com/arangodb/kube-arangodb/pkg/util" ) @@ -66,8 +68,8 @@ func Test_ArangoMLStorageSpec(t *testing.T) { core.ResourceMemory: resource.MustParse("128Mi"), }, } - s.Mode.Sidecar.ContainerTemplate = &sharedApi.ContainerTemplate{} - s.Mode.Sidecar.Resources = &sharedApi.Resources{Resources: &assignedRequirements} + s.Mode.Sidecar.Container = &schedulerContainerApi.Container{} + s.Mode.Sidecar.Resources = &schedulerContainerResourcesApi.Resources{Resources: &assignedRequirements} expectedRequirements := core.ResourceRequirements{ Requests: assignedRequirements.Requests, @@ -77,7 +79,7 @@ func Test_ArangoMLStorageSpec(t *testing.T) { }, } - actualRequirements := s.Mode.Sidecar.GetResources().With(&sharedApi.Resources{Resources: &core.ResourceRequirements{ + actualRequirements := s.Mode.Sidecar.GetResources().With(&schedulerContainerResourcesApi.Resources{Resources: &core.ResourceRequirements{ Limits: core.ResourceList{ core.ResourceCPU: resource.MustParse("100m"), core.ResourceMemory: resource.MustParse("128Mi"), @@ -87,6 +89,6 @@ func Test_ArangoMLStorageSpec(t *testing.T) { core.ResourceMemory: resource.MustParse("256Mi"), }, }}) - require.Equal(t, expectedRequirements, *actualRequirements.GetResources()) + require.Equal(t, expectedRequirements, actualRequirements.GetResources()) }) } diff --git a/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go index 18927e771..98219a607 100644 --- a/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go @@ -27,6 +27,9 @@ package v1alpha1 import ( deploymentv1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" + container "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/container" + resources "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/container/resources" + pod "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/pod" sharedv1 "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1" v1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" @@ -339,7 +342,7 @@ func (in *ArangoMLExtensionSpec) DeepCopyInto(out *ArangoMLExtensionSpec) { } if in.Image != nil { in, out := &in.Image, &out.Image - *out = new(sharedv1.Image) + *out = new(resources.Image) (*in).DeepCopyInto(*out) } if in.Init != nil { @@ -383,9 +386,9 @@ func (in *ArangoMLExtensionSpecDeployment) DeepCopyInto(out *ArangoMLExtensionSp *out = new(ArangoMLExtensionSpecDeploymentService) (*in).DeepCopyInto(*out) } - if in.PodTemplate != nil { - in, out := &in.PodTemplate, &out.PodTemplate - *out = new(sharedv1.PodTemplate) + if in.Pod != nil { + in, out := &in.Pod, &out.Pod + *out = new(pod.Pod) (*in).DeepCopyInto(*out) } if in.Prediction != nil { @@ -429,9 +432,9 @@ func (in *ArangoMLExtensionSpecDeploymentComponent) DeepCopyInto(out *ArangoMLEx *out = new(int32) **out = **in } - if in.ContainerTemplate != nil { - in, out := &in.ContainerTemplate, &out.ContainerTemplate - *out = new(sharedv1.ContainerTemplate) + if in.Container != nil { + in, out := &in.Container, &out.Container + *out = new(container.Container) (*in).DeepCopyInto(*out) } return @@ -650,14 +653,14 @@ func (in *ArangoMLExtensionStatusReconciliation) DeepCopy() *ArangoMLExtensionSt // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ArangoMLExtensionTemplate) DeepCopyInto(out *ArangoMLExtensionTemplate) { *out = *in - if in.PodTemplate != nil { - in, out := &in.PodTemplate, &out.PodTemplate - *out = new(sharedv1.PodTemplate) + if in.Pod != nil { + in, out := &in.Pod, &out.Pod + *out = new(pod.Pod) (*in).DeepCopyInto(*out) } - if in.ContainerTemplate != nil { - in, out := &in.ContainerTemplate, &out.ContainerTemplate - *out = new(sharedv1.ContainerTemplate) + if in.Container != nil { + in, out := &in.Container, &out.Container + *out = new(container.Container) (*in).DeepCopyInto(*out) } return @@ -923,9 +926,9 @@ func (in *ArangoMLStorageSpecModeSidecar) DeepCopyInto(out *ArangoMLStorageSpecM *out = new(uint16) **out = **in } - if in.ContainerTemplate != nil { - in, out := &in.ContainerTemplate, &out.ContainerTemplate - *out = new(sharedv1.ContainerTemplate) + if in.Container != nil { + in, out := &in.Container, &out.Container + *out = new(container.Container) (*in).DeepCopyInto(*out) } return diff --git a/pkg/apis/scheduler/definitions.go b/pkg/apis/scheduler/definitions.go new file mode 100644 index 000000000..916976392 --- /dev/null +++ b/pkg/apis/scheduler/definitions.go @@ -0,0 +1,25 @@ +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package scheduler + +const ( + ArangoSchedulerGroupName = "scheduler.arangodb.com" +) diff --git a/pkg/apis/scheduler/v1alpha1/container/definition.go b/pkg/apis/scheduler/v1alpha1/container/definition.go new file mode 100644 index 000000000..5c2dbf051 --- /dev/null +++ b/pkg/apis/scheduler/v1alpha1/container/definition.go @@ -0,0 +1,183 @@ +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package container + +import ( + core "k8s.io/api/core/v1" + + schedulerContainerResourcesApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/container/resources" + shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/container" +) + +type Containers map[string]Container + +func (c Containers) Apply(template *core.PodTemplateSpec) error { + if len(c) == 0 { + return nil + } + + for k, v := range c { + if id := container.GetContainerIDByName(template.Spec.Containers, k); id >= 0 { + if err := v.Apply(template, &template.Spec.Containers[id]); err != nil { + return err + } + } else { + id = len(template.Spec.Containers) + + template.Spec.Containers = append(template.Spec.Containers, core.Container{ + Name: k, + }) + + if err := v.Apply(template, &template.Spec.Containers[id]); err != nil { + return err + } + } + } + + return nil +} + +func (c Containers) With(other Containers) Containers { + if len(c) == 0 && len(other) == 0 { + return nil + } + + if len(c) == 0 { + return other.DeepCopy() + } + + if len(other) == 0 { + return c.DeepCopy() + } + + ret := Containers{} + + for k, v := range c { + if v1, ok := other[k]; !ok { + ret[k] = v + } else { + ret[k] = util.TypeOrDefault(v.With(&v1)) + } + } + + for k, v := range other { + if _, ok := c[k]; !ok { + ret[k] = v + } + } + + return ret +} + +type Container struct { + // Security keeps the security settings for Container + *schedulerContainerResourcesApi.Security `json:",inline"` + + // Environments keeps the environment variables for Container + *schedulerContainerResourcesApi.Environments `json:",inline"` + + // Image define default image used for the job + *schedulerContainerResourcesApi.Image `json:",inline"` + + // Resources define resources assigned to the pod + *schedulerContainerResourcesApi.Resources `json:",inline"` +} + +func (c *Container) Apply(template *core.PodTemplateSpec, container *core.Container) error { + if c == nil { + return nil + } + + return shared.WithErrors( + c.Security.Apply(container), + c.Environments.Apply(container), + c.Image.Apply(template, container), + c.Resources.Apply(container), + ) +} + +func (c *Container) GetImage() *schedulerContainerResourcesApi.Image { + if c == nil || c.Image == nil { + return nil + } + + return c.Image +} + +func (c *Container) GetResources() *schedulerContainerResourcesApi.Resources { + if c == nil || c.Resources == nil { + return nil + } + + return c.Resources +} + +func (c *Container) GetSecurity() *schedulerContainerResourcesApi.Security { + if c == nil || c.Security == nil { + return nil + } + + return c.Security +} + +func (c *Container) GetEnvironments() *schedulerContainerResourcesApi.Environments { + if c == nil || c.Environments == nil { + return nil + } + + return c.Environments +} + +func (c *Container) With(other *Container) *Container { + if c == nil && other == nil { + return nil + } + + if c == nil { + return other.DeepCopy() + } + + if other == nil { + return c.DeepCopy() + } + + return &Container{ + Security: c.Security.With(other.Security), + Environments: c.Environments.With(other.Environments), + Image: c.Image.With(other.Image), + Resources: c.Resources.With(other.Resources), + } +} + +func (c *Container) Validate() error { + if c == nil { + return nil + } + + return shared.WithErrors( + shared.PrefixResourceErrors("containerSecurity", c.Security.Validate()), + shared.PrefixResourceErrors("containerEnvironments", c.Environments.Validate()), + shared.PrefixResourceErrors("containerResources", c.Image.Validate()), + shared.PrefixResourceErrors("containerImage", c.Resources.Validate()), + ) +} diff --git a/pkg/apis/scheduler/v1alpha1/container/doc.go b/pkg/apis/scheduler/v1alpha1/container/doc.go new file mode 100644 index 000000000..ee9cc4b65 --- /dev/null +++ b/pkg/apis/scheduler/v1alpha1/container/doc.go @@ -0,0 +1,23 @@ +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// +k8s:deepcopy-gen=package +// +groupName=scheduler.arangodb.com +package container diff --git a/pkg/apis/scheduler/v1alpha1/container/generic.go b/pkg/apis/scheduler/v1alpha1/container/generic.go new file mode 100644 index 000000000..1c87c5dd8 --- /dev/null +++ b/pkg/apis/scheduler/v1alpha1/container/generic.go @@ -0,0 +1,99 @@ +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package container + +import ( + core "k8s.io/api/core/v1" + + schedulerContainerResourcesApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/container/resources" + shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" +) + +type Generic struct { + // Security keeps the security settings for Container + *schedulerContainerResourcesApi.Security `json:",inline"` + + // Environments keeps the environment variables for Container + *schedulerContainerResourcesApi.Environments `json:",inline"` +} + +func (c *Generic) Apply(template *core.PodTemplateSpec) error { + if c == nil { + return nil + } + + for id := range template.Spec.Containers { + if err := shared.WithErrors( + c.Security.Apply(&template.Spec.Containers[id]), + c.Environments.Apply(&template.Spec.Containers[id]), + ); err != nil { + return err + } + } + + return nil +} + +func (c *Generic) GetSecurity() *schedulerContainerResourcesApi.Security { + if c == nil || c.Security == nil { + return nil + } + + return c.Security +} + +func (c *Generic) GetEnvironments() *schedulerContainerResourcesApi.Environments { + if c == nil || c.Environments == nil { + return nil + } + + return c.Environments +} + +func (c *Generic) With(other *Generic) *Generic { + if c == nil && other == nil { + return nil + } + + if c == nil { + return other.DeepCopy() + } + + if other == nil { + return c.DeepCopy() + } + + return &Generic{ + Security: c.Security.With(other.Security), + Environments: c.Environments.With(other.Environments), + } +} + +func (c *Generic) Validate() error { + if c == nil { + return nil + } + + return shared.WithErrors( + shared.PrefixResourceErrors("containerSecurity", c.Security.Validate()), + shared.PrefixResourceErrors("containerEnvironments", c.Environments.Validate()), + ) +} diff --git a/pkg/apis/scheduler/v1alpha1/container/resources/doc.go b/pkg/apis/scheduler/v1alpha1/container/resources/doc.go new file mode 100644 index 000000000..43be1f3fb --- /dev/null +++ b/pkg/apis/scheduler/v1alpha1/container/resources/doc.go @@ -0,0 +1,23 @@ +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// +k8s:deepcopy-gen=package +// +groupName=scheduler.arangodb.com +package resources diff --git a/pkg/apis/shared/v1/envs.go b/pkg/apis/scheduler/v1alpha1/container/resources/environments.go similarity index 84% rename from pkg/apis/shared/v1/envs.go rename to pkg/apis/scheduler/v1alpha1/container/resources/environments.go index 5fc8a15ac..54d2f9e08 100644 --- a/pkg/apis/shared/v1/envs.go +++ b/pkg/apis/scheduler/v1alpha1/container/resources/environments.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany +// Copyright 2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ // Copyright holder is ArangoDB GmbH, Cologne, Germany // -package v1 +package resources import ( core "k8s.io/api/core/v1" @@ -38,6 +38,17 @@ type Environments struct { EnvFrom []core.EnvFromSource `json:"envFrom,omitempty"` } +func (e *Environments) Apply(container *core.Container) error { + if e == nil { + return nil + } + + container.Env = envs.MergeEnvs(container.Env, e.Env...) + container.EnvFrom = envs.MergeEnvFrom(container.EnvFrom, e.EnvFrom...) + + return nil +} + func (e *Environments) With(other *Environments) *Environments { if e == nil && other == nil { return nil diff --git a/pkg/apis/shared/v1/image.go b/pkg/apis/scheduler/v1alpha1/container/resources/image.go similarity index 53% rename from pkg/apis/shared/v1/image.go rename to pkg/apis/scheduler/v1alpha1/container/resources/image.go index 2f318834c..b67fedf3c 100644 --- a/pkg/apis/shared/v1/image.go +++ b/pkg/apis/scheduler/v1alpha1/container/resources/image.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,24 +18,48 @@ // Copyright holder is ArangoDB GmbH, Cologne, Germany // -package v1 +package resources import ( core "k8s.io/api/core/v1" shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" + "github.com/arangodb/kube-arangodb/pkg/util" ) +type ImagePullSecrets []string + type Image struct { // Image define image details Image *string `json:"image,omitempty"` - // PullPolicy define Image pull policy + // ImagePullPolicy define Image pull policy // +doc/default: IfNotPresent - PullPolicy *core.PullPolicy `json:"pullPolicy,omitempty"` + ImagePullPolicy *core.PullPolicy `json:"imagePullPolicy,omitempty"` - // PullSecrets define Secrets used to pull Image from registry - PullSecrets []string `json:"pullSecrets,omitempty"` + // ImagePullSecrets define Secrets used to pull Image from registry + ImagePullSecrets ImagePullSecrets `json:"imagePullSecrets,omitempty"` +} + +func (i *Image) Apply(pod *core.PodTemplateSpec, container *core.Container) error { + if i == nil { + return nil + } + + container.Image = util.WithDefault(i.Image) + container.ImagePullPolicy = util.WithDefault(i.ImagePullPolicy) + + for _, secret := range i.ImagePullSecrets { + if hasImagePullSecret(pod.Spec.ImagePullSecrets, secret) { + continue + } + + pod.Spec.ImagePullSecrets = append(pod.Spec.ImagePullSecrets, core.LocalObjectReference{ + Name: secret, + }) + } + + return nil } func (i *Image) With(other *Image) *Image { @@ -65,7 +89,17 @@ func (i *Image) Validate() error { return shared.WithErrors( shared.PrefixResourceErrors("image", shared.ValidateRequired(i.Image, shared.ValidateImage)), - shared.PrefixResourceErrors("pullPolicy", shared.ValidateOptional(i.PullPolicy, shared.ValidatePullPolicy)), - shared.PrefixResourceErrors("pullSecrets", shared.ValidateList(i.PullSecrets, shared.ValidateResourceName)), + shared.PrefixResourceErrors("imagePullPolicy", shared.ValidateOptional(i.ImagePullPolicy, shared.ValidatePullPolicy)), + shared.PrefixResourceErrors("pullSecrets", shared.ValidateList(i.ImagePullSecrets, shared.ValidateResourceName)), ) } + +func hasImagePullSecret(secrets []core.LocalObjectReference, secret string) bool { + for _, sec := range secrets { + if sec.Name == secret { + return true + } + } + + return false +} diff --git a/pkg/apis/shared/v1/resources.go b/pkg/apis/scheduler/v1alpha1/container/resources/resources.go similarity index 79% rename from pkg/apis/shared/v1/resources.go rename to pkg/apis/scheduler/v1alpha1/container/resources/resources.go index 60296f6aa..2114efd55 100644 --- a/pkg/apis/shared/v1/resources.go +++ b/pkg/apis/scheduler/v1alpha1/container/resources/resources.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany +// Copyright 2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ // Copyright holder is ArangoDB GmbH, Cologne, Germany // -package v1 +package resources import ( core "k8s.io/api/core/v1" @@ -34,6 +34,16 @@ type Resources struct { Resources *core.ResourceRequirements `json:"resources,omitempty"` } +func (r *Resources) Apply(template *core.Container) error { + if r == nil { + return nil + } + + template.Resources = util.WithDefault(r.Resources.DeepCopy()) + + return nil +} + func (r *Resources) With(newResources *Resources) *Resources { if r == nil && newResources == nil { return nil @@ -47,15 +57,15 @@ func (r *Resources) With(newResources *Resources) *Resources { return r.DeepCopy() } - return &Resources{Resources: util.NewType(resources.ApplyContainerResource(util.TypeOrDefault(r.GetResources()), util.TypeOrDefault(newResources.GetResources())))} + return &Resources{Resources: util.NewType(resources.ApplyContainerResource(r.GetResources(), newResources.GetResources()))} } -func (r *Resources) GetResources() *core.ResourceRequirements { +func (r *Resources) GetResources() core.ResourceRequirements { if r == nil || r.Resources == nil { - return nil + return core.ResourceRequirements{} } - return r.Resources + return *r.Resources } func (r *Resources) Validate() error { diff --git a/pkg/apis/shared/v1/security_container.go b/pkg/apis/scheduler/v1alpha1/container/resources/security.go similarity index 69% rename from pkg/apis/shared/v1/security_container.go rename to pkg/apis/scheduler/v1alpha1/container/resources/security.go index d8d10f934..e50e27994 100644 --- a/pkg/apis/shared/v1/security_container.go +++ b/pkg/apis/scheduler/v1alpha1/container/resources/security.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,18 +18,30 @@ // Copyright holder is ArangoDB GmbH, Cologne, Germany // -package v1 +package resources -import core "k8s.io/api/core/v1" +import ( + core "k8s.io/api/core/v1" +) -type SecurityContainer struct { +type Security struct { // PodSecurityContext holds pod-level security attributes and common container settings. // +doc/type: core.SecurityContext // +doc/link: Kubernetes docs|https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ SecurityContext *core.SecurityContext `json:"securityContext,omitempty"` } -func (s *SecurityContainer) With(other *SecurityContainer) *SecurityContainer { +func (s *Security) Apply(template *core.Container) error { + if s == nil { + return nil + } + + template.SecurityContext = s.SecurityContext.DeepCopy() + + return nil +} + +func (s *Security) With(other *Security) *Security { if s == nil && other == nil { return nil } @@ -38,19 +50,17 @@ func (s *SecurityContainer) With(other *SecurityContainer) *SecurityContainer { return s.DeepCopy() } - // TODO: Add fine graned merge - return other.DeepCopy() } -func (s *SecurityContainer) GetSecurityContext() *core.SecurityContext { +func (s *Security) GetSecurityContext() core.SecurityContext { if s == nil { - return nil + return core.SecurityContext{} } - return s.SecurityContext + return *s.SecurityContext } -func (s *SecurityContainer) Validate() error { +func (s *Security) Validate() error { return nil } diff --git a/pkg/apis/scheduler/v1alpha1/container/resources/zz_generated.deepcopy.go b/pkg/apis/scheduler/v1alpha1/container/resources/zz_generated.deepcopy.go new file mode 100644 index 000000000..0bf59ddcc --- /dev/null +++ b/pkg/apis/scheduler/v1alpha1/container/resources/zz_generated.deepcopy.go @@ -0,0 +1,153 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package resources + +import ( + v1 "k8s.io/api/core/v1" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Environments) DeepCopyInto(out *Environments) { + *out = *in + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]v1.EnvVar, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.EnvFrom != nil { + in, out := &in.EnvFrom, &out.EnvFrom + *out = make([]v1.EnvFromSource, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Environments. +func (in *Environments) DeepCopy() *Environments { + if in == nil { + return nil + } + out := new(Environments) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Image) DeepCopyInto(out *Image) { + *out = *in + if in.Image != nil { + in, out := &in.Image, &out.Image + *out = new(string) + **out = **in + } + if in.ImagePullPolicy != nil { + in, out := &in.ImagePullPolicy, &out.ImagePullPolicy + *out = new(v1.PullPolicy) + **out = **in + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make(ImagePullSecrets, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Image. +func (in *Image) DeepCopy() *Image { + if in == nil { + return nil + } + out := new(Image) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in ImagePullSecrets) DeepCopyInto(out *ImagePullSecrets) { + { + in := &in + *out = make(ImagePullSecrets, len(*in)) + copy(*out, *in) + return + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImagePullSecrets. +func (in ImagePullSecrets) DeepCopy() ImagePullSecrets { + if in == nil { + return nil + } + out := new(ImagePullSecrets) + in.DeepCopyInto(out) + return *out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Resources) DeepCopyInto(out *Resources) { + *out = *in + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(v1.ResourceRequirements) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Resources. +func (in *Resources) DeepCopy() *Resources { + if in == nil { + return nil + } + out := new(Resources) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Security) DeepCopyInto(out *Security) { + *out = *in + if in.SecurityContext != nil { + in, out := &in.SecurityContext, &out.SecurityContext + *out = new(v1.SecurityContext) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Security. +func (in *Security) DeepCopy() *Security { + if in == nil { + return nil + } + out := new(Security) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/scheduler/v1alpha1/container/zz_generated.deepcopy.go b/pkg/apis/scheduler/v1alpha1/container/zz_generated.deepcopy.go new file mode 100644 index 000000000..4203b198c --- /dev/null +++ b/pkg/apis/scheduler/v1alpha1/container/zz_generated.deepcopy.go @@ -0,0 +1,114 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package container + +import ( + resources "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/container/resources" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Container) DeepCopyInto(out *Container) { + *out = *in + if in.Security != nil { + in, out := &in.Security, &out.Security + *out = new(resources.Security) + (*in).DeepCopyInto(*out) + } + if in.Environments != nil { + in, out := &in.Environments, &out.Environments + *out = new(resources.Environments) + (*in).DeepCopyInto(*out) + } + if in.Image != nil { + in, out := &in.Image, &out.Image + *out = new(resources.Image) + (*in).DeepCopyInto(*out) + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(resources.Resources) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Container. +func (in *Container) DeepCopy() *Container { + if in == nil { + return nil + } + out := new(Container) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in Containers) DeepCopyInto(out *Containers) { + { + in := &in + *out = make(Containers, len(*in)) + for key, val := range *in { + (*out)[key] = *val.DeepCopy() + } + return + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Containers. +func (in Containers) DeepCopy() Containers { + if in == nil { + return nil + } + out := new(Containers) + in.DeepCopyInto(out) + return *out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Generic) DeepCopyInto(out *Generic) { + *out = *in + if in.Security != nil { + in, out := &in.Security, &out.Security + *out = new(resources.Security) + (*in).DeepCopyInto(*out) + } + if in.Environments != nil { + in, out := &in.Environments, &out.Environments + *out = new(resources.Environments) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Generic. +func (in *Generic) DeepCopy() *Generic { + if in == nil { + return nil + } + out := new(Generic) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/scheduler/v1alpha1/doc.go b/pkg/apis/scheduler/v1alpha1/doc.go new file mode 100644 index 000000000..23b11b19d --- /dev/null +++ b/pkg/apis/scheduler/v1alpha1/doc.go @@ -0,0 +1,23 @@ +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// +k8s:deepcopy-gen=package +// +groupName=scheduler.arangodb.com +package v1alpha1 diff --git a/pkg/apis/scheduler/v1alpha1/pod/definition.go b/pkg/apis/scheduler/v1alpha1/pod/definition.go new file mode 100644 index 000000000..a63b8cdc3 --- /dev/null +++ b/pkg/apis/scheduler/v1alpha1/pod/definition.go @@ -0,0 +1,86 @@ +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package pod + +import ( + core "k8s.io/api/core/v1" + + schedulerPodResourcesApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/pod/resources" + shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" +) + +type Pod struct { + // Scheduling keeps the scheduling information + *schedulerPodResourcesApi.Scheduling `json:",inline"` + + // Namespace keeps the Container layer Kernel namespace configuration + *schedulerPodResourcesApi.Namespace `json:",inline"` + + // Security keeps the security settings for Pod + *schedulerPodResourcesApi.Security `json:",inline"` +} + +func (a *Pod) Apply(template *core.PodTemplateSpec) error { + if a == nil { + return nil + } + + return shared.WithErrors( + a.Scheduling.Apply(template), + a.Namespace.Apply(template), + a.Security.Apply(template), + ) +} + +func (a *Pod) GetSecurity() *schedulerPodResourcesApi.Security { + if a == nil { + return nil + } + + return a.Security +} + +func (a *Pod) GetScheduling() *schedulerPodResourcesApi.Scheduling { + if a == nil { + return nil + } + + return a.Scheduling +} + +func (a *Pod) GetContainerNamespace() *schedulerPodResourcesApi.Namespace { + if a == nil { + return nil + } + + return a.Namespace +} + +func (a *Pod) Validate() error { + if a == nil { + return nil + } + return shared.WithErrors( + a.Scheduling.Validate(), + a.Namespace.Validate(), + a.Security.Validate(), + ) +} diff --git a/pkg/apis/scheduler/v1alpha1/pod/doc.go b/pkg/apis/scheduler/v1alpha1/pod/doc.go new file mode 100644 index 000000000..7978454ce --- /dev/null +++ b/pkg/apis/scheduler/v1alpha1/pod/doc.go @@ -0,0 +1,23 @@ +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// +k8s:deepcopy-gen=package +// +groupName=scheduler.arangodb.com +package pod diff --git a/pkg/apis/scheduler/v1alpha1/pod/resources/doc.go b/pkg/apis/scheduler/v1alpha1/pod/resources/doc.go new file mode 100644 index 000000000..43be1f3fb --- /dev/null +++ b/pkg/apis/scheduler/v1alpha1/pod/resources/doc.go @@ -0,0 +1,23 @@ +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// +k8s:deepcopy-gen=package +// +groupName=scheduler.arangodb.com +package resources diff --git a/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go b/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go new file mode 100644 index 000000000..9a467f824 --- /dev/null +++ b/pkg/apis/scheduler/v1alpha1/pod/resources/namespace.go @@ -0,0 +1,120 @@ +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package resources + +import ( + core "k8s.io/api/core/v1" + + "github.com/arangodb/kube-arangodb/pkg/util" +) + +type Namespace struct { + // HostNetwork requests Host network for this pod. Use the host's network namespace. + // If this option is set, the ports that will be used must be specified. + // +doc/default: false + HostNetwork *bool `json:"hostNetwork,omitempty" protobuf:"varint,11,opt,name=hostNetwork"` + // HostPID define to use the host's pid namespace. + // +doc/default: false + HostPID *bool `json:"hostPID,omitempty" protobuf:"varint,12,opt,name=hostPID"` + // HostIPC defines to use the host's ipc namespace. + // +doc/default: false + HostIPC *bool `json:"hostIPC,omitempty" protobuf:"varint,13,opt,name=hostIPC"` + // ShareProcessNamespace defines to share a single process namespace between all of the containers in a pod. + // When this is set containers will be able to view and signal processes from other containers + // in the same pod, and the first process in each container will not be assigned PID 1. + // HostPID and ShareProcessNamespace cannot both be set. + // +doc/default: false + ShareProcessNamespace *bool `json:"shareProcessNamespace,omitempty" protobuf:"varint,27,opt,name=shareProcessNamespace"` +} + +func (n *Namespace) Apply(template *core.PodTemplateSpec) error { + if n == nil { + return nil + } + + template.Spec.HostNetwork = util.WithDefault(n.HostNetwork) + template.Spec.HostPID = util.WithDefault(n.HostPID) + template.Spec.HostIPC = util.WithDefault(n.HostIPC) + if v := n.ShareProcessNamespace; v != nil { + template.Spec.ShareProcessNamespace = util.NewType(*v) + } else { + template.Spec.ShareProcessNamespace = nil + } + + return nil +} + +func (n *Namespace) GetHostNetwork() *bool { + if n == nil || n.HostNetwork == nil { + return nil + } + + return n.HostNetwork +} + +func (n *Namespace) GetHostPID() *bool { + if n == nil || n.HostPID == nil { + return nil + } + + return n.HostPID +} + +func (n *Namespace) GetHostIPC() *bool { + if n == nil || n.HostIPC == nil { + return nil + } + + return n.HostIPC +} + +func (n *Namespace) GetShareProcessNamespace() *bool { + if n == nil { + return nil + } + + return n.ShareProcessNamespace +} + +func (n *Namespace) With(other *Namespace) *Namespace { + if n == nil && other == nil { + return nil + } + + if n == nil { + return other.DeepCopy() + } + + if other == nil { + return n.DeepCopy() + } + + return &Namespace{ + HostNetwork: util.First(other.HostNetwork, n.HostNetwork), + HostPID: util.First(other.HostPID, n.HostPID), + HostIPC: util.First(other.HostIPC, n.HostIPC), + ShareProcessNamespace: util.First(other.ShareProcessNamespace, n.ShareProcessNamespace), + } +} + +func (n *Namespace) Validate() error { + return nil +} diff --git a/pkg/apis/shared/v1/scheduling.go b/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go similarity index 53% rename from pkg/apis/shared/v1/scheduling.go rename to pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go index 340f7028e..f72cd3a9b 100644 --- a/pkg/apis/shared/v1/scheduling.go +++ b/pkg/apis/scheduler/v1alpha1/pod/resources/scheduling.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,13 +18,17 @@ // Copyright holder is ArangoDB GmbH, Cologne, Germany // -package v1 +package resources import ( core "k8s.io/api/core/v1" + + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/arangodb/kube-arangodb/pkg/util/affinity" + "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/tolerations" ) -type SchedulingTolerations []core.Toleration +type Tolerations []core.Toleration type Scheduling struct { // NodeSelector is a selector that must be true for the workload to fit on a node. @@ -39,7 +43,7 @@ type Scheduling struct { // Tolerations defines tolerations // +doc/type: []core.Toleration // +doc/link: Kubernetes docs|https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/ - Tolerations SchedulingTolerations `json:"tolerations,omitempty"` + Tolerations Tolerations `json:"tolerations,omitempty"` // SchedulerName specifies, the pod will be dispatched by specified scheduler. // If not specified, the pod will be dispatched by default scheduler. @@ -47,6 +51,28 @@ type Scheduling struct { SchedulerName *string `json:"schedulerName,omitempty"` } +func (s *Scheduling) Apply(template *core.PodTemplateSpec) error { + if s == nil { + return nil + } + + if len(s.NodeSelector) == 0 { + template.Spec.NodeSelector = nil + } else { + template.Spec.NodeSelector = map[string]string{} + for k, v := range s.NodeSelector { + template.Spec.NodeSelector[k] = v + } + } + + template.Spec.Affinity = s.Affinity.DeepCopy() + template.Spec.Tolerations = s.Tolerations.DeepCopy() + + template.Spec.SchedulerName = util.WithDefault(s.SchedulerName) + + return nil +} + func (s *Scheduling) GetNodeSelector() map[string]string { if s != nil { return s.NodeSelector @@ -71,7 +97,7 @@ func (s *Scheduling) GetAffinity() *core.Affinity { return nil } -func (s *Scheduling) GetTolerations() SchedulingTolerations { +func (s *Scheduling) GetTolerations() Tolerations { if s != nil { return s.Tolerations } @@ -79,6 +105,54 @@ func (s *Scheduling) GetTolerations() SchedulingTolerations { return nil } +func (s *Scheduling) With(other *Scheduling) *Scheduling { + if s == nil && other == nil { + return nil + } + + if other == nil { + return s.DeepCopy() + } + + if s == nil { + return other.DeepCopy() + } + + current := s.DeepCopy() + new := other.DeepCopy() + + // NodeSelector + if len(current.NodeSelector) == 0 { + current.NodeSelector = new.NodeSelector + } else if len(new.NodeSelector) > 0 { + for k, v := range new.NodeSelector { + other.NodeSelector[k] = v + } + } + + // SchedulerName + if new.SchedulerName != nil { + other.SchedulerName = new.SchedulerName + } + + // Tolerations + new.Tolerations = tolerations.AddTolerationsIfNotFound(new.Tolerations, other.Tolerations...) + + // Affinity + current.Affinity = affinity.Merge(current.Affinity, new.Affinity) + + // return + + if current.Affinity == nil && + current.SchedulerName == nil && + len(current.Tolerations) == 0 && + len(current.NodeSelector) == 0 { + return nil + } + + return current +} + func (s *Scheduling) Validate() error { return nil } diff --git a/pkg/apis/shared/v1/security_pod.go b/pkg/apis/scheduler/v1alpha1/pod/resources/security.go similarity index 61% rename from pkg/apis/shared/v1/security_pod.go rename to pkg/apis/scheduler/v1alpha1/pod/resources/security.go index 3d788b4c3..4308430c4 100644 --- a/pkg/apis/shared/v1/security_pod.go +++ b/pkg/apis/scheduler/v1alpha1/pod/resources/security.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,18 +18,30 @@ // Copyright holder is ArangoDB GmbH, Cologne, Germany // -package v1 +package resources -import core "k8s.io/api/core/v1" +import ( + core "k8s.io/api/core/v1" +) -type SecurityPod struct { +type Security struct { // PodSecurityContext holds pod-level security attributes and common container settings. // +doc/type: core.PodSecurityContext // +doc/link: Kubernetes docs|https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ PodSecurityContext *core.PodSecurityContext `json:"podSecurityContext,omitempty"` } -func (s *SecurityPod) GetPodSecurityContext() *core.PodSecurityContext { +func (s *Security) Apply(template *core.PodTemplateSpec) error { + if s == nil { + return nil + } + + template.Spec.SecurityContext = s.PodSecurityContext.DeepCopy() + + return nil +} + +func (s *Security) GetSecurityContext() *core.PodSecurityContext { if s == nil { return nil } @@ -37,6 +49,22 @@ func (s *SecurityPod) GetPodSecurityContext() *core.PodSecurityContext { return s.PodSecurityContext } -func (s *SecurityPod) Validate() error { +func (s *Security) With(newResources *Security) *Security { + if s == nil && newResources == nil { + return nil + } + + if s == nil { + return newResources.DeepCopy() + } + + if newResources == nil { + return s.DeepCopy() + } + + return nil +} + +func (s *Security) Validate() error { return nil } diff --git a/pkg/apis/scheduler/v1alpha1/pod/resources/zz_generated.deepcopy.go b/pkg/apis/scheduler/v1alpha1/pod/resources/zz_generated.deepcopy.go new file mode 100644 index 000000000..46a17dfe2 --- /dev/null +++ b/pkg/apis/scheduler/v1alpha1/pod/resources/zz_generated.deepcopy.go @@ -0,0 +1,149 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package resources + +import ( + v1 "k8s.io/api/core/v1" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Namespace) DeepCopyInto(out *Namespace) { + *out = *in + if in.HostNetwork != nil { + in, out := &in.HostNetwork, &out.HostNetwork + *out = new(bool) + **out = **in + } + if in.HostPID != nil { + in, out := &in.HostPID, &out.HostPID + *out = new(bool) + **out = **in + } + if in.HostIPC != nil { + in, out := &in.HostIPC, &out.HostIPC + *out = new(bool) + **out = **in + } + if in.ShareProcessNamespace != nil { + in, out := &in.ShareProcessNamespace, &out.ShareProcessNamespace + *out = new(bool) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Namespace. +func (in *Namespace) DeepCopy() *Namespace { + if in == nil { + return nil + } + out := new(Namespace) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Scheduling) DeepCopyInto(out *Scheduling) { + *out = *in + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Affinity != nil { + in, out := &in.Affinity, &out.Affinity + *out = new(v1.Affinity) + (*in).DeepCopyInto(*out) + } + if in.Tolerations != nil { + in, out := &in.Tolerations, &out.Tolerations + *out = make(Tolerations, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.SchedulerName != nil { + in, out := &in.SchedulerName, &out.SchedulerName + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Scheduling. +func (in *Scheduling) DeepCopy() *Scheduling { + if in == nil { + return nil + } + out := new(Scheduling) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Security) DeepCopyInto(out *Security) { + *out = *in + if in.PodSecurityContext != nil { + in, out := &in.PodSecurityContext, &out.PodSecurityContext + *out = new(v1.PodSecurityContext) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Security. +func (in *Security) DeepCopy() *Security { + if in == nil { + return nil + } + out := new(Security) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in Tolerations) DeepCopyInto(out *Tolerations) { + { + in := &in + *out = make(Tolerations, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + return + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Tolerations. +func (in Tolerations) DeepCopy() Tolerations { + if in == nil { + return nil + } + out := new(Tolerations) + in.DeepCopyInto(out) + return *out +} diff --git a/pkg/apis/scheduler/v1alpha1/pod/zz_generated.deepcopy.go b/pkg/apis/scheduler/v1alpha1/pod/zz_generated.deepcopy.go new file mode 100644 index 000000000..c8287b6f1 --- /dev/null +++ b/pkg/apis/scheduler/v1alpha1/pod/zz_generated.deepcopy.go @@ -0,0 +1,61 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package pod + +import ( + resources "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/pod/resources" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Pod) DeepCopyInto(out *Pod) { + *out = *in + if in.Scheduling != nil { + in, out := &in.Scheduling, &out.Scheduling + *out = new(resources.Scheduling) + (*in).DeepCopyInto(*out) + } + if in.Namespace != nil { + in, out := &in.Namespace, &out.Namespace + *out = new(resources.Namespace) + (*in).DeepCopyInto(*out) + } + if in.Security != nil { + in, out := &in.Security, &out.Security + *out = new(resources.Security) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Pod. +func (in *Pod) DeepCopy() *Pod { + if in == nil { + return nil + } + out := new(Pod) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/scheduler/v1alpha1/register.go b/pkg/apis/scheduler/v1alpha1/register.go new file mode 100644 index 000000000..70e098a1e --- /dev/null +++ b/pkg/apis/scheduler/v1alpha1/register.go @@ -0,0 +1,53 @@ +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package v1alpha1 + +import ( + meta "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + + "github.com/arangodb/kube-arangodb/pkg/apis/scheduler" +) + +const ( + ArangoSchedulerVersion = "v1alpha1" +) + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme + + SchemeGroupVersion = schema.GroupVersion{Group: scheduler.ArangoSchedulerGroupName, + Version: ArangoSchedulerVersion} +) + +// Resource gets an ArangoCluster GroupResource for a specified resource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +// addKnownTypes adds the set of types defined in this package to the supplied scheme. +func addKnownTypes(s *runtime.Scheme) error { + s.AddKnownTypes(SchemeGroupVersion) + meta.AddToGroupVersion(s, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/scheduler/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/scheduler/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 000000000..8c33820b3 --- /dev/null +++ b/pkg/apis/scheduler/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,26 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 diff --git a/pkg/apis/shared/v1/container_namespace.go b/pkg/apis/shared/v1/container_namespace.go deleted file mode 100644 index 248683ef0..000000000 --- a/pkg/apis/shared/v1/container_namespace.go +++ /dev/null @@ -1,76 +0,0 @@ -// -// DISCLAIMER -// -// Copyright 2023 ArangoDB GmbH, Cologne, Germany -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Copyright holder is ArangoDB GmbH, Cologne, Germany -// - -package v1 - -type ContainerNamespace struct { - // HostNetwork requests Host network for this pod. Use the host's network namespace. - // If this option is set, the ports that will be used must be specified. - // +doc/default: false - HostNetwork bool `json:"hostNetwork,omitempty" protobuf:"varint,11,opt,name=hostNetwork"` - // HostPID define to use the host's pid namespace. - // +doc/default: false - HostPID bool `json:"hostPID,omitempty" protobuf:"varint,12,opt,name=hostPID"` - // HostIPC defines to use the host's ipc namespace. - // +doc/default: false - HostIPC bool `json:"hostIPC,omitempty" protobuf:"varint,13,opt,name=hostIPC"` - // ShareProcessNamespace defines to share a single process namespace between all of the containers in a pod. - // When this is set containers will be able to view and signal processes from other containers - // in the same pod, and the first process in each container will not be assigned PID 1. - // HostPID and ShareProcessNamespace cannot both be set. - // +doc/default: false - ShareProcessNamespace *bool `json:"shareProcessNamespace,omitempty" protobuf:"varint,27,opt,name=shareProcessNamespace"` -} - -func (c *ContainerNamespace) GetHostNetwork() bool { - if c == nil { - return false - } - - return c.HostNetwork -} - -func (c *ContainerNamespace) GetHostPID() bool { - if c == nil { - return false - } - - return c.HostPID -} - -func (c *ContainerNamespace) GetHostIPC() bool { - if c == nil { - return false - } - - return c.HostIPC -} - -func (c *ContainerNamespace) GetShareProcessNamespace() *bool { - if c == nil { - return nil - } - - return c.ShareProcessNamespace -} - -func (c *ContainerNamespace) Validate() error { - return nil -} diff --git a/pkg/apis/shared/v1/core_container_spec.go b/pkg/apis/shared/v1/core_container_spec.go deleted file mode 100644 index 29eaa0d41..000000000 --- a/pkg/apis/shared/v1/core_container_spec.go +++ /dev/null @@ -1,104 +0,0 @@ -// -// DISCLAIMER -// -// Copyright 2023 ArangoDB GmbH, Cologne, Germany -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Copyright holder is ArangoDB GmbH, Cologne, Germany -// - -package v1 - -import ( - shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" -) - -type ContainerTemplate struct { - // Image define default image used for the job - *Image `json:",inline"` - - // Resources define resources assigned to the pod - *Resources `json:",inline"` - - // SecurityContainer keeps the security settings for Container - *SecurityContainer `json:",inline"` - - // Environments keeps the environment variables for Container - *Environments `json:",inline"` -} - -func (a *ContainerTemplate) With(other *ContainerTemplate) *ContainerTemplate { - if a == nil && other == nil { - return nil - } - - if a == nil { - return other.DeepCopy() - } - - if other == nil { - return a.DeepCopy() - } - - return &ContainerTemplate{ - Image: a.GetImage().With(other.GetImage()), - Resources: a.GetResources().With(other.GetResources()), - SecurityContainer: a.GetSecurityContainer().With(other.GetSecurityContainer()), - Environments: a.GetEnvironments().With(other.GetEnvironments()), - } -} - -func (a *ContainerTemplate) GetImage() *Image { - if a == nil || a.Image == nil { - return nil - } - - return a.Image -} - -func (a *ContainerTemplate) GetSecurityContainer() *SecurityContainer { - if a == nil || a.SecurityContainer == nil { - return nil - } - - return a.SecurityContainer -} - -func (a *ContainerTemplate) GetEnvironments() *Environments { - if a == nil || a.Environments == nil { - return nil - } - - return a.Environments -} - -func (a *ContainerTemplate) GetResources() *Resources { - if a == nil || a.Resources == nil { - return nil - } - - return a.Resources -} - -func (a *ContainerTemplate) Validate() error { - if a == nil { - return nil - } - return shared.WithErrors( - a.GetImage().Validate(), - a.GetResources().Validate(), - a.GetSecurityContainer().Validate(), - a.GetEnvironments().Validate(), - ) -} diff --git a/pkg/apis/shared/v1/core_pod_spec.go b/pkg/apis/shared/v1/core_pod_spec.go deleted file mode 100644 index 087bc55e3..000000000 --- a/pkg/apis/shared/v1/core_pod_spec.go +++ /dev/null @@ -1,69 +0,0 @@ -// -// DISCLAIMER -// -// Copyright 2023 ArangoDB GmbH, Cologne, Germany -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Copyright holder is ArangoDB GmbH, Cologne, Germany -// - -package v1 - -import shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" - -type PodTemplate struct { - // Scheduling keeps the scheduling information - *Scheduling `json:",inline"` - - // ContainerNamespace keeps the Container layer Kernel namespace configuration - *ContainerNamespace `json:",inline"` - - // SecurityPod keeps the security settings for Pod - *SecurityPod `json:",inline"` -} - -func (a *PodTemplate) GetSecurityPod() *SecurityPod { - if a == nil { - return nil - } - - return a.SecurityPod -} - -func (a *PodTemplate) GetScheduling() *Scheduling { - if a == nil { - return nil - } - - return a.Scheduling -} - -func (a *PodTemplate) GetContainerNamespace() *ContainerNamespace { - if a == nil { - return nil - } - - return a.ContainerNamespace -} - -func (a *PodTemplate) Validate() error { - if a == nil { - return nil - } - return shared.WithErrors( - a.GetScheduling().Validate(), - a.GetContainerNamespace().Validate(), - a.GetSecurityPod().Validate(), - ) -} diff --git a/pkg/apis/shared/v1/zz_generated.deepcopy.go b/pkg/apis/shared/v1/zz_generated.deepcopy.go index 582db12af..1ac9e9d82 100644 --- a/pkg/apis/shared/v1/zz_generated.deepcopy.go +++ b/pkg/apis/shared/v1/zz_generated.deepcopy.go @@ -26,97 +26,9 @@ package v1 import ( - corev1 "k8s.io/api/core/v1" types "k8s.io/apimachinery/pkg/types" ) -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ContainerNamespace) DeepCopyInto(out *ContainerNamespace) { - *out = *in - if in.ShareProcessNamespace != nil { - in, out := &in.ShareProcessNamespace, &out.ShareProcessNamespace - *out = new(bool) - **out = **in - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerNamespace. -func (in *ContainerNamespace) DeepCopy() *ContainerNamespace { - if in == nil { - return nil - } - out := new(ContainerNamespace) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ContainerTemplate) DeepCopyInto(out *ContainerTemplate) { - *out = *in - if in.Image != nil { - in, out := &in.Image, &out.Image - *out = new(Image) - (*in).DeepCopyInto(*out) - } - if in.Resources != nil { - in, out := &in.Resources, &out.Resources - *out = new(Resources) - (*in).DeepCopyInto(*out) - } - if in.SecurityContainer != nil { - in, out := &in.SecurityContainer, &out.SecurityContainer - *out = new(SecurityContainer) - (*in).DeepCopyInto(*out) - } - if in.Environments != nil { - in, out := &in.Environments, &out.Environments - *out = new(Environments) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerTemplate. -func (in *ContainerTemplate) DeepCopy() *ContainerTemplate { - if in == nil { - return nil - } - out := new(ContainerTemplate) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Environments) DeepCopyInto(out *Environments) { - *out = *in - if in.Env != nil { - in, out := &in.Env, &out.Env - *out = make([]corev1.EnvVar, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.EnvFrom != nil { - in, out := &in.EnvFrom, &out.EnvFrom - *out = make([]corev1.EnvFromSource, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Environments. -func (in *Environments) DeepCopy() *Environments { - if in == nil { - return nil - } - out := new(Environments) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in HashList) DeepCopyInto(out *HashList) { { @@ -137,37 +49,6 @@ func (in HashList) DeepCopy() HashList { return *out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Image) DeepCopyInto(out *Image) { - *out = *in - if in.Image != nil { - in, out := &in.Image, &out.Image - *out = new(string) - **out = **in - } - if in.PullPolicy != nil { - in, out := &in.PullPolicy, &out.PullPolicy - *out = new(corev1.PullPolicy) - **out = **in - } - if in.PullSecrets != nil { - in, out := &in.PullSecrets, &out.PullSecrets - *out = make([]string, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Image. -func (in *Image) DeepCopy() *Image { - if in == nil { - return nil - } - out := new(Image) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Object) DeepCopyInto(out *Object) { *out = *in @@ -194,162 +75,6 @@ func (in *Object) DeepCopy() *Object { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PodTemplate) DeepCopyInto(out *PodTemplate) { - *out = *in - if in.Scheduling != nil { - in, out := &in.Scheduling, &out.Scheduling - *out = new(Scheduling) - (*in).DeepCopyInto(*out) - } - if in.ContainerNamespace != nil { - in, out := &in.ContainerNamespace, &out.ContainerNamespace - *out = new(ContainerNamespace) - (*in).DeepCopyInto(*out) - } - if in.SecurityPod != nil { - in, out := &in.SecurityPod, &out.SecurityPod - *out = new(SecurityPod) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodTemplate. -func (in *PodTemplate) DeepCopy() *PodTemplate { - if in == nil { - return nil - } - out := new(PodTemplate) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Resources) DeepCopyInto(out *Resources) { - *out = *in - if in.Resources != nil { - in, out := &in.Resources, &out.Resources - *out = new(corev1.ResourceRequirements) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Resources. -func (in *Resources) DeepCopy() *Resources { - if in == nil { - return nil - } - out := new(Resources) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Scheduling) DeepCopyInto(out *Scheduling) { - *out = *in - if in.NodeSelector != nil { - in, out := &in.NodeSelector, &out.NodeSelector - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.Affinity != nil { - in, out := &in.Affinity, &out.Affinity - *out = new(corev1.Affinity) - (*in).DeepCopyInto(*out) - } - if in.Tolerations != nil { - in, out := &in.Tolerations, &out.Tolerations - *out = make(SchedulingTolerations, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.SchedulerName != nil { - in, out := &in.SchedulerName, &out.SchedulerName - *out = new(string) - **out = **in - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Scheduling. -func (in *Scheduling) DeepCopy() *Scheduling { - if in == nil { - return nil - } - out := new(Scheduling) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in SchedulingTolerations) DeepCopyInto(out *SchedulingTolerations) { - { - in := &in - *out = make(SchedulingTolerations, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - return - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SchedulingTolerations. -func (in SchedulingTolerations) DeepCopy() SchedulingTolerations { - if in == nil { - return nil - } - out := new(SchedulingTolerations) - in.DeepCopyInto(out) - return *out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SecurityContainer) DeepCopyInto(out *SecurityContainer) { - *out = *in - if in.SecurityContext != nil { - in, out := &in.SecurityContext, &out.SecurityContext - *out = new(corev1.SecurityContext) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecurityContainer. -func (in *SecurityContainer) DeepCopy() *SecurityContainer { - if in == nil { - return nil - } - out := new(SecurityContainer) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SecurityPod) DeepCopyInto(out *SecurityPod) { - *out = *in - if in.PodSecurityContext != nil { - in, out := &in.PodSecurityContext, &out.PodSecurityContext - *out = new(corev1.PodSecurityContext) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecurityPod. -func (in *SecurityPod) DeepCopy() *SecurityPod { - if in == nil { - return nil - } - out := new(SecurityPod) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ServiceAccount) DeepCopyInto(out *ServiceAccount) { *out = *in diff --git a/pkg/crd/crds/ml-extension.schema.generated.yaml b/pkg/crd/crds/ml-extension.schema.generated.yaml index 9a313dbcf..a09c4d2b1 100644 --- a/pkg/crd/crds/ml-extension.schema.generated.yaml +++ b/pkg/crd/crds/ml-extension.schema.generated.yaml @@ -7,7 +7,6 @@ v1alpha1: description: Deployment specifies how the ML extension will be deployed into cluster properties: affinity: - description: Affinity defines scheduling constraints for workload properties: nodeAffinity: properties: @@ -307,23 +306,16 @@ v1alpha1: type: object type: object hostIPC: - description: HostIPC defines to use the host's ipc namespace. type: boolean hostNetwork: - description: |- - HostNetwork requests Host network for this pod. Use the host's network namespace. - If this option is set, the ports that will be used must be specified. type: boolean hostPID: - description: HostPID define to use the host's pid namespace. type: boolean nodeSelector: additionalProperties: type: string - description: NodeSelector is a selector that must be true for the workload to fit on a node. type: object podSecurityContext: - description: PodSecurityContext holds pod-level security attributes and common container settings. properties: fsGroup: format: int64 @@ -386,7 +378,6 @@ v1alpha1: description: Prediction defines how Prediction workload will be deployed properties: env: - description: Env keeps the information about environment variables provided to the container items: properties: name: @@ -433,7 +424,6 @@ v1alpha1: type: object type: array envFrom: - description: EnvFrom keeps the information about environment variable sources provided to the container items: properties: configMapRef: @@ -458,22 +448,18 @@ v1alpha1: description: GPU defined if GPU Jobs are enabled for component. In use only for ArangoMLExtensionSpecDeploymentComponentPrediction and ArangoMLExtensionSpecDeploymentComponentTraining type: boolean image: - description: Image define image details type: string - port: - description: Port defines on which port the container will be listening for connections - format: int32 - type: integer - pullPolicy: - description: PullPolicy define Image pull policy + imagePullPolicy: type: string - pullSecrets: - description: PullSecrets define Secrets used to pull Image from registry + imagePullSecrets: items: type: string type: array + port: + description: Port defines on which port the container will be listening for connections + format: int32 + type: integer resources: - description: Resources holds resource requests & limits for container properties: claims: items: @@ -492,7 +478,6 @@ v1alpha1: type: object type: object securityContext: - description: PodSecurityContext holds pod-level security attributes and common container settings. properties: allowPrivilegeEscalation: type: boolean @@ -556,7 +541,6 @@ v1alpha1: description: Project defines how Project workload will be deployed properties: env: - description: Env keeps the information about environment variables provided to the container items: properties: name: @@ -603,7 +587,6 @@ v1alpha1: type: object type: array envFrom: - description: EnvFrom keeps the information about environment variable sources provided to the container items: properties: configMapRef: @@ -628,22 +611,18 @@ v1alpha1: description: GPU defined if GPU Jobs are enabled for component. In use only for ArangoMLExtensionSpecDeploymentComponentPrediction and ArangoMLExtensionSpecDeploymentComponentTraining type: boolean image: - description: Image define image details type: string - port: - description: Port defines on which port the container will be listening for connections - format: int32 - type: integer - pullPolicy: - description: PullPolicy define Image pull policy + imagePullPolicy: type: string - pullSecrets: - description: PullSecrets define Secrets used to pull Image from registry + imagePullSecrets: items: type: string type: array + port: + description: Port defines on which port the container will be listening for connections + format: int32 + type: integer resources: - description: Resources holds resource requests & limits for container properties: claims: items: @@ -662,7 +641,6 @@ v1alpha1: type: object type: object securityContext: - description: PodSecurityContext holds pod-level security attributes and common container settings. properties: allowPrivilegeEscalation: type: boolean @@ -727,9 +705,6 @@ v1alpha1: format: int32 type: integer schedulerName: - description: |- - SchedulerName specifies, the pod will be dispatched by specified scheduler. - If not specified, the pod will be dispatched by default scheduler. type: string service: description: Service defines how components will be exposed @@ -744,14 +719,8 @@ v1alpha1: type: string type: object shareProcessNamespace: - description: |- - ShareProcessNamespace defines to share a single process namespace between all of the containers in a pod. - When this is set containers will be able to view and signal processes from other containers - in the same pod, and the first process in each container will not be assigned PID 1. - HostPID and ShareProcessNamespace cannot both be set. type: boolean tolerations: - description: Tolerations defines tolerations items: properties: effect: @@ -771,7 +740,6 @@ v1alpha1: description: Training defines how Training workload will be deployed properties: env: - description: Env keeps the information about environment variables provided to the container items: properties: name: @@ -818,7 +786,6 @@ v1alpha1: type: object type: array envFrom: - description: EnvFrom keeps the information about environment variable sources provided to the container items: properties: configMapRef: @@ -843,22 +810,18 @@ v1alpha1: description: GPU defined if GPU Jobs are enabled for component. In use only for ArangoMLExtensionSpecDeploymentComponentPrediction and ArangoMLExtensionSpecDeploymentComponentTraining type: boolean image: - description: Image define image details type: string - port: - description: Port defines on which port the container will be listening for connections - format: int32 - type: integer - pullPolicy: - description: PullPolicy define Image pull policy + imagePullPolicy: type: string - pullSecrets: - description: PullSecrets define Secrets used to pull Image from registry + imagePullSecrets: items: type: string type: array + port: + description: Port defines on which port the container will be listening for connections + format: int32 + type: integer resources: - description: Resources holds resource requests & limits for container properties: claims: items: @@ -877,7 +840,6 @@ v1alpha1: type: object type: object securityContext: - description: PodSecurityContext holds pod-level security attributes and common container settings. properties: allowPrivilegeEscalation: type: boolean @@ -939,13 +901,17 @@ v1alpha1: type: object type: object image: - description: Image define image details type: string + imagePullPolicy: + type: string + imagePullSecrets: + items: + type: string + type: array init: description: ArangoMLExtensionTemplate define Init job specification properties: affinity: - description: Affinity defines scheduling constraints for workload properties: nodeAffinity: properties: @@ -1245,7 +1211,6 @@ v1alpha1: type: object type: object env: - description: Env keeps the information about environment variables provided to the container items: properties: name: @@ -1292,7 +1257,6 @@ v1alpha1: type: object type: array envFrom: - description: EnvFrom keeps the information about environment variable sources provided to the container items: properties: configMapRef: @@ -1314,26 +1278,24 @@ v1alpha1: type: object type: array hostIPC: - description: HostIPC defines to use the host's ipc namespace. type: boolean hostNetwork: - description: |- - HostNetwork requests Host network for this pod. Use the host's network namespace. - If this option is set, the ports that will be used must be specified. type: boolean hostPID: - description: HostPID define to use the host's pid namespace. type: boolean image: - description: Image define image details type: string + imagePullPolicy: + type: string + imagePullSecrets: + items: + type: string + type: array nodeSelector: additionalProperties: type: string - description: NodeSelector is a selector that must be true for the workload to fit on a node. type: object podSecurityContext: - description: PodSecurityContext holds pod-level security attributes and common container settings. properties: fsGroup: format: int64 @@ -1392,16 +1354,7 @@ v1alpha1: type: string type: object type: object - pullPolicy: - description: PullPolicy define Image pull policy - type: string - pullSecrets: - description: PullSecrets define Secrets used to pull Image from registry - items: - type: string - type: array resources: - description: Resources holds resource requests & limits for container properties: claims: items: @@ -1420,12 +1373,8 @@ v1alpha1: type: object type: object schedulerName: - description: |- - SchedulerName specifies, the pod will be dispatched by specified scheduler. - If not specified, the pod will be dispatched by default scheduler. type: string securityContext: - description: PodSecurityContext holds pod-level security attributes and common container settings. properties: allowPrivilegeEscalation: type: boolean @@ -1485,14 +1434,8 @@ v1alpha1: type: object type: object shareProcessNamespace: - description: |- - ShareProcessNamespace defines to share a single process namespace between all of the containers in a pod. - When this is set containers will be able to view and signal processes from other containers - in the same pod, and the first process in each container will not be assigned PID 1. - HostPID and ShareProcessNamespace cannot both be set. type: boolean tolerations: - description: Tolerations defines tolerations items: properties: effect: @@ -1519,7 +1462,6 @@ v1alpha1: description: CPU defines templates for CPU jobs properties: affinity: - description: Affinity defines scheduling constraints for workload properties: nodeAffinity: properties: @@ -1819,7 +1761,6 @@ v1alpha1: type: object type: object env: - description: Env keeps the information about environment variables provided to the container items: properties: name: @@ -1866,7 +1807,6 @@ v1alpha1: type: object type: array envFrom: - description: EnvFrom keeps the information about environment variable sources provided to the container items: properties: configMapRef: @@ -1888,26 +1828,24 @@ v1alpha1: type: object type: array hostIPC: - description: HostIPC defines to use the host's ipc namespace. type: boolean hostNetwork: - description: |- - HostNetwork requests Host network for this pod. Use the host's network namespace. - If this option is set, the ports that will be used must be specified. type: boolean hostPID: - description: HostPID define to use the host's pid namespace. type: boolean image: - description: Image define image details type: string + imagePullPolicy: + type: string + imagePullSecrets: + items: + type: string + type: array nodeSelector: additionalProperties: type: string - description: NodeSelector is a selector that must be true for the workload to fit on a node. type: object podSecurityContext: - description: PodSecurityContext holds pod-level security attributes and common container settings. properties: fsGroup: format: int64 @@ -1966,16 +1904,7 @@ v1alpha1: type: string type: object type: object - pullPolicy: - description: PullPolicy define Image pull policy - type: string - pullSecrets: - description: PullSecrets define Secrets used to pull Image from registry - items: - type: string - type: array resources: - description: Resources holds resource requests & limits for container properties: claims: items: @@ -1994,12 +1923,8 @@ v1alpha1: type: object type: object schedulerName: - description: |- - SchedulerName specifies, the pod will be dispatched by specified scheduler. - If not specified, the pod will be dispatched by default scheduler. type: string securityContext: - description: PodSecurityContext holds pod-level security attributes and common container settings. properties: allowPrivilegeEscalation: type: boolean @@ -2059,14 +1984,8 @@ v1alpha1: type: object type: object shareProcessNamespace: - description: |- - ShareProcessNamespace defines to share a single process namespace between all of the containers in a pod. - When this is set containers will be able to view and signal processes from other containers - in the same pod, and the first process in each container will not be assigned PID 1. - HostPID and ShareProcessNamespace cannot both be set. type: boolean tolerations: - description: Tolerations defines tolerations items: properties: effect: @@ -2087,7 +2006,6 @@ v1alpha1: description: GPU defines templates for GPU jobs properties: affinity: - description: Affinity defines scheduling constraints for workload properties: nodeAffinity: properties: @@ -2387,7 +2305,6 @@ v1alpha1: type: object type: object env: - description: Env keeps the information about environment variables provided to the container items: properties: name: @@ -2434,7 +2351,6 @@ v1alpha1: type: object type: array envFrom: - description: EnvFrom keeps the information about environment variable sources provided to the container items: properties: configMapRef: @@ -2456,26 +2372,24 @@ v1alpha1: type: object type: array hostIPC: - description: HostIPC defines to use the host's ipc namespace. type: boolean hostNetwork: - description: |- - HostNetwork requests Host network for this pod. Use the host's network namespace. - If this option is set, the ports that will be used must be specified. type: boolean hostPID: - description: HostPID define to use the host's pid namespace. type: boolean image: - description: Image define image details type: string + imagePullPolicy: + type: string + imagePullSecrets: + items: + type: string + type: array nodeSelector: additionalProperties: type: string - description: NodeSelector is a selector that must be true for the workload to fit on a node. type: object podSecurityContext: - description: PodSecurityContext holds pod-level security attributes and common container settings. properties: fsGroup: format: int64 @@ -2534,16 +2448,7 @@ v1alpha1: type: string type: object type: object - pullPolicy: - description: PullPolicy define Image pull policy - type: string - pullSecrets: - description: PullSecrets define Secrets used to pull Image from registry - items: - type: string - type: array resources: - description: Resources holds resource requests & limits for container properties: claims: items: @@ -2562,12 +2467,8 @@ v1alpha1: type: object type: object schedulerName: - description: |- - SchedulerName specifies, the pod will be dispatched by specified scheduler. - If not specified, the pod will be dispatched by default scheduler. type: string securityContext: - description: PodSecurityContext holds pod-level security attributes and common container settings. properties: allowPrivilegeEscalation: type: boolean @@ -2627,14 +2528,8 @@ v1alpha1: type: object type: object shareProcessNamespace: - description: |- - ShareProcessNamespace defines to share a single process namespace between all of the containers in a pod. - When this is set containers will be able to view and signal processes from other containers - in the same pod, and the first process in each container will not be assigned PID 1. - HostPID and ShareProcessNamespace cannot both be set. type: boolean tolerations: - description: Tolerations defines tolerations items: properties: effect: @@ -2659,7 +2554,6 @@ v1alpha1: description: CPU defines templates for CPU jobs properties: affinity: - description: Affinity defines scheduling constraints for workload properties: nodeAffinity: properties: @@ -2959,7 +2853,6 @@ v1alpha1: type: object type: object env: - description: Env keeps the information about environment variables provided to the container items: properties: name: @@ -3006,7 +2899,6 @@ v1alpha1: type: object type: array envFrom: - description: EnvFrom keeps the information about environment variable sources provided to the container items: properties: configMapRef: @@ -3028,26 +2920,24 @@ v1alpha1: type: object type: array hostIPC: - description: HostIPC defines to use the host's ipc namespace. type: boolean hostNetwork: - description: |- - HostNetwork requests Host network for this pod. Use the host's network namespace. - If this option is set, the ports that will be used must be specified. type: boolean hostPID: - description: HostPID define to use the host's pid namespace. type: boolean image: - description: Image define image details type: string + imagePullPolicy: + type: string + imagePullSecrets: + items: + type: string + type: array nodeSelector: additionalProperties: type: string - description: NodeSelector is a selector that must be true for the workload to fit on a node. type: object podSecurityContext: - description: PodSecurityContext holds pod-level security attributes and common container settings. properties: fsGroup: format: int64 @@ -3106,16 +2996,7 @@ v1alpha1: type: string type: object type: object - pullPolicy: - description: PullPolicy define Image pull policy - type: string - pullSecrets: - description: PullSecrets define Secrets used to pull Image from registry - items: - type: string - type: array resources: - description: Resources holds resource requests & limits for container properties: claims: items: @@ -3134,12 +3015,8 @@ v1alpha1: type: object type: object schedulerName: - description: |- - SchedulerName specifies, the pod will be dispatched by specified scheduler. - If not specified, the pod will be dispatched by default scheduler. type: string securityContext: - description: PodSecurityContext holds pod-level security attributes and common container settings. properties: allowPrivilegeEscalation: type: boolean @@ -3199,14 +3076,8 @@ v1alpha1: type: object type: object shareProcessNamespace: - description: |- - ShareProcessNamespace defines to share a single process namespace between all of the containers in a pod. - When this is set containers will be able to view and signal processes from other containers - in the same pod, and the first process in each container will not be assigned PID 1. - HostPID and ShareProcessNamespace cannot both be set. type: boolean tolerations: - description: Tolerations defines tolerations items: properties: effect: @@ -3227,7 +3098,6 @@ v1alpha1: description: GPU defines templates for GPU jobs properties: affinity: - description: Affinity defines scheduling constraints for workload properties: nodeAffinity: properties: @@ -3527,7 +3397,6 @@ v1alpha1: type: object type: object env: - description: Env keeps the information about environment variables provided to the container items: properties: name: @@ -3574,7 +3443,6 @@ v1alpha1: type: object type: array envFrom: - description: EnvFrom keeps the information about environment variable sources provided to the container items: properties: configMapRef: @@ -3596,26 +3464,24 @@ v1alpha1: type: object type: array hostIPC: - description: HostIPC defines to use the host's ipc namespace. type: boolean hostNetwork: - description: |- - HostNetwork requests Host network for this pod. Use the host's network namespace. - If this option is set, the ports that will be used must be specified. type: boolean hostPID: - description: HostPID define to use the host's pid namespace. type: boolean image: - description: Image define image details type: string + imagePullPolicy: + type: string + imagePullSecrets: + items: + type: string + type: array nodeSelector: additionalProperties: type: string - description: NodeSelector is a selector that must be true for the workload to fit on a node. type: object podSecurityContext: - description: PodSecurityContext holds pod-level security attributes and common container settings. properties: fsGroup: format: int64 @@ -3674,16 +3540,7 @@ v1alpha1: type: string type: object type: object - pullPolicy: - description: PullPolicy define Image pull policy - type: string - pullSecrets: - description: PullSecrets define Secrets used to pull Image from registry - items: - type: string - type: array resources: - description: Resources holds resource requests & limits for container properties: claims: items: @@ -3702,12 +3559,8 @@ v1alpha1: type: object type: object schedulerName: - description: |- - SchedulerName specifies, the pod will be dispatched by specified scheduler. - If not specified, the pod will be dispatched by default scheduler. type: string securityContext: - description: PodSecurityContext holds pod-level security attributes and common container settings. properties: allowPrivilegeEscalation: type: boolean @@ -3767,14 +3620,8 @@ v1alpha1: type: object type: object shareProcessNamespace: - description: |- - ShareProcessNamespace defines to share a single process namespace between all of the containers in a pod. - When this is set containers will be able to view and signal processes from other containers - in the same pod, and the first process in each container will not be assigned PID 1. - HostPID and ShareProcessNamespace cannot both be set. type: boolean tolerations: - description: Tolerations defines tolerations items: properties: effect: @@ -3799,7 +3646,6 @@ v1alpha1: description: CPU defines templates for CPU jobs properties: affinity: - description: Affinity defines scheduling constraints for workload properties: nodeAffinity: properties: @@ -4099,7 +3945,6 @@ v1alpha1: type: object type: object env: - description: Env keeps the information about environment variables provided to the container items: properties: name: @@ -4146,7 +3991,6 @@ v1alpha1: type: object type: array envFrom: - description: EnvFrom keeps the information about environment variable sources provided to the container items: properties: configMapRef: @@ -4168,26 +4012,24 @@ v1alpha1: type: object type: array hostIPC: - description: HostIPC defines to use the host's ipc namespace. type: boolean hostNetwork: - description: |- - HostNetwork requests Host network for this pod. Use the host's network namespace. - If this option is set, the ports that will be used must be specified. type: boolean hostPID: - description: HostPID define to use the host's pid namespace. type: boolean image: - description: Image define image details type: string + imagePullPolicy: + type: string + imagePullSecrets: + items: + type: string + type: array nodeSelector: additionalProperties: type: string - description: NodeSelector is a selector that must be true for the workload to fit on a node. type: object podSecurityContext: - description: PodSecurityContext holds pod-level security attributes and common container settings. properties: fsGroup: format: int64 @@ -4246,16 +4088,7 @@ v1alpha1: type: string type: object type: object - pullPolicy: - description: PullPolicy define Image pull policy - type: string - pullSecrets: - description: PullSecrets define Secrets used to pull Image from registry - items: - type: string - type: array resources: - description: Resources holds resource requests & limits for container properties: claims: items: @@ -4274,12 +4107,8 @@ v1alpha1: type: object type: object schedulerName: - description: |- - SchedulerName specifies, the pod will be dispatched by specified scheduler. - If not specified, the pod will be dispatched by default scheduler. type: string securityContext: - description: PodSecurityContext holds pod-level security attributes and common container settings. properties: allowPrivilegeEscalation: type: boolean @@ -4339,14 +4168,8 @@ v1alpha1: type: object type: object shareProcessNamespace: - description: |- - ShareProcessNamespace defines to share a single process namespace between all of the containers in a pod. - When this is set containers will be able to view and signal processes from other containers - in the same pod, and the first process in each container will not be assigned PID 1. - HostPID and ShareProcessNamespace cannot both be set. type: boolean tolerations: - description: Tolerations defines tolerations items: properties: effect: @@ -4367,7 +4190,6 @@ v1alpha1: description: GPU defines templates for GPU jobs properties: affinity: - description: Affinity defines scheduling constraints for workload properties: nodeAffinity: properties: @@ -4667,7 +4489,6 @@ v1alpha1: type: object type: object env: - description: Env keeps the information about environment variables provided to the container items: properties: name: @@ -4714,7 +4535,6 @@ v1alpha1: type: object type: array envFrom: - description: EnvFrom keeps the information about environment variable sources provided to the container items: properties: configMapRef: @@ -4736,26 +4556,24 @@ v1alpha1: type: object type: array hostIPC: - description: HostIPC defines to use the host's ipc namespace. type: boolean hostNetwork: - description: |- - HostNetwork requests Host network for this pod. Use the host's network namespace. - If this option is set, the ports that will be used must be specified. type: boolean hostPID: - description: HostPID define to use the host's pid namespace. type: boolean image: - description: Image define image details type: string + imagePullPolicy: + type: string + imagePullSecrets: + items: + type: string + type: array nodeSelector: additionalProperties: type: string - description: NodeSelector is a selector that must be true for the workload to fit on a node. type: object podSecurityContext: - description: PodSecurityContext holds pod-level security attributes and common container settings. properties: fsGroup: format: int64 @@ -4814,16 +4632,7 @@ v1alpha1: type: string type: object type: object - pullPolicy: - description: PullPolicy define Image pull policy - type: string - pullSecrets: - description: PullSecrets define Secrets used to pull Image from registry - items: - type: string - type: array resources: - description: Resources holds resource requests & limits for container properties: claims: items: @@ -4842,12 +4651,8 @@ v1alpha1: type: object type: object schedulerName: - description: |- - SchedulerName specifies, the pod will be dispatched by specified scheduler. - If not specified, the pod will be dispatched by default scheduler. type: string securityContext: - description: PodSecurityContext holds pod-level security attributes and common container settings. properties: allowPrivilegeEscalation: type: boolean @@ -4907,14 +4712,8 @@ v1alpha1: type: object type: object shareProcessNamespace: - description: |- - ShareProcessNamespace defines to share a single process namespace between all of the containers in a pod. - When this is set containers will be able to view and signal processes from other containers - in the same pod, and the first process in each container will not be assigned PID 1. - HostPID and ShareProcessNamespace cannot both be set. type: boolean tolerations: - description: Tolerations defines tolerations items: properties: effect: @@ -4947,14 +4746,6 @@ v1alpha1: type: string type: object type: object - pullPolicy: - description: PullPolicy define Image pull policy - type: string - pullSecrets: - description: PullSecrets define Secrets used to pull Image from registry - items: - type: string - type: array storage: description: Storage specifies the ArangoMLStorage used within Extension properties: diff --git a/pkg/crd/crds/ml-storage.schema.generated.yaml b/pkg/crd/crds/ml-storage.schema.generated.yaml index c6fdf6e09..633f6780b 100644 --- a/pkg/crd/crds/ml-storage.schema.generated.yaml +++ b/pkg/crd/crds/ml-storage.schema.generated.yaml @@ -73,7 +73,6 @@ v1alpha1: format: int32 type: integer env: - description: Env keeps the information about environment variables provided to the container items: properties: name: @@ -120,7 +119,6 @@ v1alpha1: type: object type: array envFrom: - description: EnvFrom keeps the information about environment variable sources provided to the container items: properties: configMapRef: @@ -142,22 +140,18 @@ v1alpha1: type: object type: array image: - description: Image define image details type: string - listenPort: - description: ListenPort defines on which port the sidecar container will be listening for connections - format: int32 - type: integer - pullPolicy: - description: PullPolicy define Image pull policy + imagePullPolicy: type: string - pullSecrets: - description: PullSecrets define Secrets used to pull Image from registry + imagePullSecrets: items: type: string type: array + listenPort: + description: ListenPort defines on which port the sidecar container will be listening for connections + format: int32 + type: integer resources: - description: Resources holds resource requests & limits for container properties: claims: items: @@ -176,7 +170,6 @@ v1alpha1: type: object type: object securityContext: - description: PodSecurityContext holds pod-level security attributes and common container settings. properties: allowPrivilegeEscalation: type: boolean diff --git a/pkg/deployment/deployment_suite_test.go b/pkg/deployment/deployment_suite_test.go index c0322c16a..3be1ce8cc 100644 --- a/pkg/deployment/deployment_suite_test.go +++ b/pkg/deployment/deployment_suite_test.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -53,6 +53,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/util" "github.com/arangodb/kube-arangodb/pkg/util/constants" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" + "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/container" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/throttle" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/probes" "github.com/arangodb/kube-arangodb/pkg/util/kclient" @@ -892,7 +893,7 @@ func addLifecycle(name string, uuidRequired bool, license string, group api.Serv p.Spec.Containers[0].VolumeMounts = append(p.Spec.Containers[0].VolumeMounts, k8sutil.LifecycleVolumeMount()) } - if _, ok := k8sutil.GetAnyContainerByName(p.Spec.InitContainers, "init-lifecycle"); !ok { + if _, ok := container.GetAnyContainerByName(p.Spec.InitContainers, "init-lifecycle"); !ok { p.Spec.InitContainers = append( []core.Container{createTestLifecycleContainer(emptyResources)}, p.Spec.InitContainers..., @@ -900,7 +901,7 @@ func addLifecycle(name string, uuidRequired bool, license string, group api.Serv } } - if _, ok := k8sutil.GetAnyContainerByName(p.Spec.InitContainers, "uuid"); !ok { + if _, ok := container.GetAnyContainerByName(p.Spec.InitContainers, "uuid"); !ok { binaryPath, _ := os.Executable() p.Spec.InitContainers = append( []core.Container{ diff --git a/pkg/deployment/images.go b/pkg/deployment/images.go index 8f10e929b..b0684f88b 100644 --- a/pkg/deployment/images.go +++ b/pkg/deployment/images.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/handlers/utils" "github.com/arangodb/kube-arangodb/pkg/logging" "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/arangodb/kube-arangodb/pkg/util/affinity" "github.com/arangodb/kube-arangodb/pkg/util/arangod" "github.com/arangodb/kube-arangodb/pkg/util/constants" "github.com/arangodb/kube-arangodb/pkg/util/errors" @@ -358,30 +359,30 @@ func (i *ImageUpdatePod) GetServiceAccountName() string { } func (i *ImageUpdatePod) GetPodAntiAffinity() *core.PodAntiAffinity { - a := core.PodAntiAffinity{} + a := &core.PodAntiAffinity{} - pod.AppendPodAntiAffinityDefault(i, &a) + pod.AppendPodAntiAffinityDefault(i, a) - pod.MergePodAntiAffinity(&a, i.spec.ID.Get().AntiAffinity) + a = affinity.MergePodAntiAffinity(a, i.spec.ID.Get().AntiAffinity) - return pod.ReturnPodAntiAffinityOrNil(a) + return affinity.OptionalPodAntiAffinity(a) } func (i *ImageUpdatePod) GetPodAffinity() *core.PodAffinity { - a := core.PodAffinity{} + a := &core.PodAffinity{} - pod.MergePodAffinity(&a, i.spec.ID.Get().Affinity) + a = affinity.MergePodAffinity(a, i.spec.ID.Get().Affinity) - return pod.ReturnPodAffinityOrNil(a) + return affinity.OptionalPodAffinity(a) } func (i *ImageUpdatePod) GetNodeAffinity() *core.NodeAffinity { - a := core.NodeAffinity{} - pod.AppendArchSelector(&a, i.spec.Architecture.AsNodeSelectorRequirement()) + a := &core.NodeAffinity{} + pod.AppendArchSelector(a, i.spec.Architecture.AsNodeSelectorRequirement()) - pod.MergeNodeAffinity(&a, i.spec.ID.Get().NodeAffinity) + a = affinity.MergeNodeAffinity(a, i.spec.ID.Get().NodeAffinity) - return pod.ReturnNodeAffinityOrNil(a) + return affinity.OptionalNodeAffinity(a) } func (i *ImageUpdatePod) Validate(_ interfaces.Inspector) error { diff --git a/pkg/deployment/pod/affinity.go b/pkg/deployment/pod/affinity.go index 6329372bf..b66f0741d 100644 --- a/pkg/deployment/pod/affinity.go +++ b/pkg/deployment/pod/affinity.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -93,89 +93,3 @@ func AppendAffinityWithRole(p interfaces.PodCreator, a *core.PodAffinity, role s }, }) } - -func MergePodAntiAffinity(a, b *core.PodAntiAffinity) { - if a == nil || b == nil { - return - } - - a.PreferredDuringSchedulingIgnoredDuringExecution = append(a.PreferredDuringSchedulingIgnoredDuringExecution, - b.PreferredDuringSchedulingIgnoredDuringExecution...) - - a.RequiredDuringSchedulingIgnoredDuringExecution = append(a.RequiredDuringSchedulingIgnoredDuringExecution, - b.RequiredDuringSchedulingIgnoredDuringExecution...) -} - -func MergePodAffinity(a, b *core.PodAffinity) { - if a == nil || b == nil { - return - } - - a.PreferredDuringSchedulingIgnoredDuringExecution = append(a.PreferredDuringSchedulingIgnoredDuringExecution, - b.PreferredDuringSchedulingIgnoredDuringExecution...) - - a.RequiredDuringSchedulingIgnoredDuringExecution = append(a.RequiredDuringSchedulingIgnoredDuringExecution, - b.RequiredDuringSchedulingIgnoredDuringExecution...) -} - -func MergeNodeAffinity(a, b *core.NodeAffinity) { - if a == nil || b == nil { - return - } - - a.PreferredDuringSchedulingIgnoredDuringExecution = append(a.PreferredDuringSchedulingIgnoredDuringExecution, - b.PreferredDuringSchedulingIgnoredDuringExecution...) - - var newSelectorTerms []core.NodeSelectorTerm - - if b.RequiredDuringSchedulingIgnoredDuringExecution == nil || len(b.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms) == 0 { - newSelectorTerms = a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms - } else if a.RequiredDuringSchedulingIgnoredDuringExecution == nil || len(a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms) == 0 { - newSelectorTerms = b.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms - } else { - for _, aTerms := range a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms { - for _, bTerms := range b.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms { - term := aTerms.DeepCopy() - if len(bTerms.MatchExpressions) != 0 { - term.MatchExpressions = append(term.MatchExpressions, bTerms.MatchExpressions...) - } - if len(bTerms.MatchFields) != 0 { - term.MatchFields = append(term.MatchFields, bTerms.MatchFields...) - } - newSelectorTerms = append(newSelectorTerms, *term) - } - } - } - - a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms = newSelectorTerms -} - -func ReturnPodAffinityOrNil(a core.PodAffinity) *core.PodAffinity { - if len(a.RequiredDuringSchedulingIgnoredDuringExecution) > 0 || len(a.PreferredDuringSchedulingIgnoredDuringExecution) > 0 { - return &a - } - - return nil -} - -func ReturnPodAntiAffinityOrNil(a core.PodAntiAffinity) *core.PodAntiAffinity { - if len(a.RequiredDuringSchedulingIgnoredDuringExecution) > 0 || len(a.PreferredDuringSchedulingIgnoredDuringExecution) > 0 { - return &a - } - - return nil -} - -func ReturnNodeAffinityOrNil(a core.NodeAffinity) *core.NodeAffinity { - if len(a.PreferredDuringSchedulingIgnoredDuringExecution) > 0 { - return &a - } - - if s := a.RequiredDuringSchedulingIgnoredDuringExecution; s != nil { - if len(s.NodeSelectorTerms) > 0 { - return &a - } - } - - return nil -} diff --git a/pkg/deployment/reconcile/action_runtime_container_image_update.go b/pkg/deployment/reconcile/action_runtime_container_image_update.go index 66c504fe0..e7fb768b0 100644 --- a/pkg/deployment/reconcile/action_runtime_container_image_update.go +++ b/pkg/deployment/reconcile/action_runtime_container_image_update.go @@ -31,6 +31,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/deployment/rotation" "github.com/arangodb/kube-arangodb/pkg/util/errors" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" + "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/container" ) func newRuntimeContainerImageUpdateAction(action api.Action, actionCtx ActionContext) Action { @@ -285,13 +286,13 @@ func (a actionRuntimeContainerImageUpdate) CheckProgress(ctx context.Context) (b return true, false, nil } - cspec, ok := k8sutil.GetContainerByName(pod, name) + cspec, ok := container.GetContainerByName(pod, name) if !ok { a.log.Info("Unable to find container spec") return true, false, nil } - cstatus, ok := k8sutil.GetContainerStatusByName(pod, name) + cstatus, ok := container.GetContainerStatusByName(pod, name) if !ok { a.log.Info("Unable to find container status") return true, false, nil diff --git a/pkg/deployment/resources/pod_creator_arangod.go b/pkg/deployment/resources/pod_creator_arangod.go index f8b898db0..5c46437c7 100644 --- a/pkg/deployment/resources/pod_creator_arangod.go +++ b/pkg/deployment/resources/pod_creator_arangod.go @@ -35,6 +35,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/deployment/pod" "github.com/arangodb/kube-arangodb/pkg/deployment/topology" "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/arangodb/kube-arangodb/pkg/util/affinity" "github.com/arangodb/kube-arangodb/pkg/util/collection" "github.com/arangodb/kube-arangodb/pkg/util/constants" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" @@ -367,37 +368,37 @@ func (m *MemberArangoDPod) GetImagePullSecrets() []string { } func (m *MemberArangoDPod) GetPodAntiAffinity() *core.PodAntiAffinity { - a := core.PodAntiAffinity{} + a := &core.PodAntiAffinity{} - pod.AppendPodAntiAffinityDefault(m, &a) + pod.AppendPodAntiAffinityDefault(m, a) - pod.MergePodAntiAffinity(&a, topology.GetTopologyAffinityRules(m.context.GetName(), m.deploymentStatus, m.group, m.status).PodAntiAffinity) + a = affinity.MergePodAntiAffinity(a, topology.GetTopologyAffinityRules(m.context.GetName(), m.deploymentStatus, m.group, m.status).PodAntiAffinity) - pod.MergePodAntiAffinity(&a, m.groupSpec.AntiAffinity) + a = affinity.MergePodAntiAffinity(a, m.groupSpec.AntiAffinity) - return pod.ReturnPodAntiAffinityOrNil(a) + return affinity.OptionalPodAntiAffinity(a) } func (m *MemberArangoDPod) GetPodAffinity() *core.PodAffinity { - a := core.PodAffinity{} + a := &core.PodAffinity{} - pod.MergePodAffinity(&a, m.groupSpec.Affinity) + a = affinity.MergePodAffinity(a, m.groupSpec.Affinity) - pod.MergePodAffinity(&a, topology.GetTopologyAffinityRules(m.context.GetName(), m.deploymentStatus, m.group, m.status).PodAffinity) + a = affinity.MergePodAffinity(a, topology.GetTopologyAffinityRules(m.context.GetName(), m.deploymentStatus, m.group, m.status).PodAffinity) - return pod.ReturnPodAffinityOrNil(a) + return affinity.OptionalPodAffinity(a) } func (m *MemberArangoDPod) GetNodeAffinity() *core.NodeAffinity { - a := core.NodeAffinity{} + a := &core.NodeAffinity{} - pod.AppendArchSelector(&a, m.status.Architecture.Default(m.spec.Architecture.GetDefault()).AsNodeSelectorRequirement()) + pod.AppendArchSelector(a, m.status.Architecture.Default(m.spec.Architecture.GetDefault()).AsNodeSelectorRequirement()) - pod.MergeNodeAffinity(&a, m.groupSpec.NodeAffinity) + a = affinity.MergeNodeAffinity(a, m.groupSpec.NodeAffinity) - pod.MergeNodeAffinity(&a, topology.GetTopologyAffinityRules(m.context.GetName(), m.deploymentStatus, m.group, m.status).NodeAffinity) + a = affinity.MergeNodeAffinity(a, topology.GetTopologyAffinityRules(m.context.GetName(), m.deploymentStatus, m.group, m.status).NodeAffinity) - return pod.ReturnNodeAffinityOrNil(a) + return affinity.OptionalNodeAffinity(a) } func (m *MemberArangoDPod) GetNodeSelector() map[string]string { diff --git a/pkg/deployment/resources/pod_creator_sync.go b/pkg/deployment/resources/pod_creator_sync.go index c73a674f6..2ef1710e6 100644 --- a/pkg/deployment/resources/pod_creator_sync.go +++ b/pkg/deployment/resources/pod_creator_sync.go @@ -36,6 +36,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/deployment/features" "github.com/arangodb/kube-arangodb/pkg/deployment/pod" "github.com/arangodb/kube-arangodb/pkg/handlers/utils" + "github.com/arangodb/kube-arangodb/pkg/util/affinity" "github.com/arangodb/kube-arangodb/pkg/util/collection" "github.com/arangodb/kube-arangodb/pkg/util/constants" "github.com/arangodb/kube-arangodb/pkg/util/errors" @@ -227,35 +228,35 @@ func (m *MemberSyncPod) GetImagePullSecrets() []string { } func (m *MemberSyncPod) GetPodAntiAffinity() *core.PodAntiAffinity { - a := core.PodAntiAffinity{} + a := &core.PodAntiAffinity{} - pod.AppendPodAntiAffinityDefault(m, &a) + pod.AppendPodAntiAffinityDefault(m, a) - pod.MergePodAntiAffinity(&a, m.groupSpec.AntiAffinity) + a = affinity.MergePodAntiAffinity(a, m.groupSpec.AntiAffinity) - return pod.ReturnPodAntiAffinityOrNil(a) + return affinity.OptionalPodAntiAffinity(a) } func (m *MemberSyncPod) GetPodAffinity() *core.PodAffinity { - a := core.PodAffinity{} + a := &core.PodAffinity{} if m.group == api.ServerGroupSyncWorkers { - pod.AppendAffinityWithRole(m, &a, api.ServerGroupDBServers.AsRole()) + pod.AppendAffinityWithRole(m, a, api.ServerGroupDBServers.AsRole()) } - pod.MergePodAffinity(&a, m.groupSpec.Affinity) + a = affinity.MergePodAffinity(a, m.groupSpec.Affinity) - return pod.ReturnPodAffinityOrNil(a) + return affinity.OptionalPodAffinity(a) } func (m *MemberSyncPod) GetNodeAffinity() *core.NodeAffinity { - a := core.NodeAffinity{} + a := &core.NodeAffinity{} - pod.AppendArchSelector(&a, m.memberStatus.Architecture.Default(m.spec.Architecture.GetDefault()).AsNodeSelectorRequirement()) + pod.AppendArchSelector(a, m.memberStatus.Architecture.Default(m.spec.Architecture.GetDefault()).AsNodeSelectorRequirement()) - pod.MergeNodeAffinity(&a, m.groupSpec.NodeAffinity) + a = affinity.MergeNodeAffinity(a, m.groupSpec.NodeAffinity) - return pod.ReturnNodeAffinityOrNil(a) + return affinity.OptionalNodeAffinity(a) } func (m *MemberSyncPod) GetNodeSelector() map[string]string { diff --git a/pkg/deployment/resources/pod_inspector.go b/pkg/deployment/resources/pod_inspector.go index 54c63b142..97c0a990c 100644 --- a/pkg/deployment/resources/pod_inspector.go +++ b/pkg/deployment/resources/pod_inspector.go @@ -39,6 +39,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/util/errors" "github.com/arangodb/kube-arangodb/pkg/util/globals" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" + "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/container" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/info" inspectorInterface "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector" podv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/pod/v1" @@ -60,7 +61,7 @@ const ( ) func (r *Resources) handleRestartedPod(pod *core.Pod, memberStatus *api.MemberStatus, wasTerminated, markAsTerminated *bool) { - containerStatus, exist := k8sutil.GetContainerStatusByName(pod, api.ServerGroupReservedContainerNameServer) + containerStatus, exist := container.GetContainerStatusByName(pod, api.ServerGroupReservedContainerNameServer) if exist && containerStatus.State.Terminated != nil { // do not record termination time again in the code below *wasTerminated = true @@ -177,11 +178,11 @@ func (r *Resources) InspectPods(ctx context.Context, cachedStatus inspectorInter } if markAsTerminated && memberStatus.Conditions.Update(api.ConditionTypeTerminated, true, "Pod Failed", "") { - if containers := k8sutil.GetFailedContainerNames(pod.Status.InitContainerStatuses); len(containers) > 0 { - for _, container := range containers { - switch container { + if containers := container.GetFailedContainerNames(pod.Status.InitContainerStatuses); len(containers) > 0 { + for id := range containers { + switch containers[id] { case api.ServerGroupReservedInitContainerNameVersionCheck: - if c, ok := k8sutil.GetAnyContainerStatusByName(pod.Status.InitContainerStatuses, container); ok { + if c, ok := container.GetAnyContainerStatusByName(pod.Status.InitContainerStatuses, containers[id]); ok { if t := c.State.Terminated; t != nil && t.ExitCode == 11 { memberStatus.Upgrade = true updateMemberStatusNeeded = true @@ -191,11 +192,11 @@ func (r *Resources) InspectPods(ctx context.Context, cachedStatus inspectorInter memberStatus.Conditions.Update(api.ConditionTypeUpgradeFailed, true, "Upgrade Failed", "") } - if c, ok := k8sutil.GetAnyContainerStatusByName(pod.Status.InitContainerStatuses, container); ok { + if c, ok := container.GetAnyContainerStatusByName(pod.Status.InitContainerStatuses, containers[id]); ok { if t := c.State.Terminated; t != nil && t.ExitCode != 0 { log.Str("member", memberStatus.ID). Str("pod", pod.GetName()). - Str("container", container). + Str("container", containers[id]). Str("uid", string(pod.GetUID())). Int32("exit-code", t.ExitCode). Str("reason", t.Reason). @@ -205,19 +206,19 @@ func (r *Resources) InspectPods(ctx context.Context, cachedStatus inspectorInter Time("finished", t.FinishedAt.Time). Warn("Pod failed in unexpected way: Init Container failed") - r.metrics.IncMemberInitContainerRestarts(memberStatus.ID, container, t.Reason, t.ExitCode) + r.metrics.IncMemberInitContainerRestarts(memberStatus.ID, containers[id], t.Reason, t.ExitCode) } } } } - if containers := k8sutil.GetFailedContainerNames(pod.Status.ContainerStatuses); len(containers) > 0 { - for _, container := range containers { - if c, ok := k8sutil.GetAnyContainerStatusByName(pod.Status.ContainerStatuses, container); ok { + if containers := container.GetFailedContainerNames(pod.Status.ContainerStatuses); len(containers) > 0 { + for id := range containers { + if c, ok := container.GetAnyContainerStatusByName(pod.Status.ContainerStatuses, containers[id]); ok { if t := c.State.Terminated; t != nil && t.ExitCode != 0 { log.Str("member", memberStatus.ID). Str("pod", pod.GetName()). - Str("container", container). + Str("container", containers[id]). Str("uid", string(pod.GetUID())). Int32("exit-code", t.ExitCode). Str("reason", t.Reason). @@ -227,7 +228,7 @@ func (r *Resources) InspectPods(ctx context.Context, cachedStatus inspectorInter Time("finished", t.FinishedAt.Time). Warn("Pod failed in unexpected way: Core Container failed") - r.metrics.IncMemberContainerRestarts(memberStatus.ID, container, t.Reason, t.ExitCode) + r.metrics.IncMemberContainerRestarts(memberStatus.ID, containers[id], t.Reason, t.ExitCode) } } } diff --git a/pkg/deployment/resources/pod_termination.go b/pkg/deployment/resources/pod_termination.go index 99ef7168e..1d6272c5a 100644 --- a/pkg/deployment/resources/pod_termination.go +++ b/pkg/deployment/resources/pod_termination.go @@ -34,6 +34,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/util/errors" "github.com/arangodb/kube-arangodb/pkg/util/globals" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" + "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/container" ) // prepareAgencyPodTermination checks if the given agency pod is allowed to terminate @@ -174,7 +175,7 @@ func (r *Resources) prepareDBServerPodTermination(ctx context.Context, p *core.P log.Err(err).Debug("Failed to access cluster") if r.context.GetSpec().Recovery.Get().GetAutoRecover() { - if c, ok := k8sutil.GetContainerStatusByName(p, shared.ServerContainerName); ok { + if c, ok := container.GetContainerStatusByName(p, shared.ServerContainerName); ok { if t := c.State.Terminated; t != nil { return nil } diff --git a/pkg/generated/clientset/versioned/clientset.go b/pkg/generated/clientset/versioned/clientset.go index 71da9622f..9757effe5 100644 --- a/pkg/generated/clientset/versioned/clientset.go +++ b/pkg/generated/clientset/versioned/clientset.go @@ -33,6 +33,7 @@ import ( mlv1alpha1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/ml/v1alpha1" replicationv1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/replication/v1" replicationv2alpha1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/replication/v2alpha1" + schedulerv1alpha1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/scheduler/v1alpha1" storagev1alpha "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/storage/v1alpha" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" @@ -48,6 +49,7 @@ type Interface interface { MlV1alpha1() mlv1alpha1.MlV1alpha1Interface ReplicationV1() replicationv1.ReplicationV1Interface ReplicationV2alpha1() replicationv2alpha1.ReplicationV2alpha1Interface + SchedulerV1alpha1() schedulerv1alpha1.SchedulerV1alpha1Interface StorageV1alpha() storagev1alpha.StorageV1alphaInterface } @@ -61,6 +63,7 @@ type Clientset struct { mlV1alpha1 *mlv1alpha1.MlV1alpha1Client replicationV1 *replicationv1.ReplicationV1Client replicationV2alpha1 *replicationv2alpha1.ReplicationV2alpha1Client + schedulerV1alpha1 *schedulerv1alpha1.SchedulerV1alpha1Client storageV1alpha *storagev1alpha.StorageV1alphaClient } @@ -99,6 +102,11 @@ func (c *Clientset) ReplicationV2alpha1() replicationv2alpha1.ReplicationV2alpha return c.replicationV2alpha1 } +// SchedulerV1alpha1 retrieves the SchedulerV1alpha1Client +func (c *Clientset) SchedulerV1alpha1() schedulerv1alpha1.SchedulerV1alpha1Interface { + return c.schedulerV1alpha1 +} + // StorageV1alpha retrieves the StorageV1alphaClient func (c *Clientset) StorageV1alpha() storagev1alpha.StorageV1alphaInterface { return c.storageV1alpha @@ -176,6 +184,10 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, if err != nil { return nil, err } + cs.schedulerV1alpha1, err = schedulerv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } cs.storageV1alpha, err = storagev1alpha.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err @@ -208,6 +220,7 @@ func New(c rest.Interface) *Clientset { cs.mlV1alpha1 = mlv1alpha1.New(c) cs.replicationV1 = replicationv1.New(c) cs.replicationV2alpha1 = replicationv2alpha1.New(c) + cs.schedulerV1alpha1 = schedulerv1alpha1.New(c) cs.storageV1alpha = storagev1alpha.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) diff --git a/pkg/generated/clientset/versioned/fake/clientset_generated.go b/pkg/generated/clientset/versioned/fake/clientset_generated.go index 5f173750e..bbdc529b9 100644 --- a/pkg/generated/clientset/versioned/fake/clientset_generated.go +++ b/pkg/generated/clientset/versioned/fake/clientset_generated.go @@ -38,6 +38,8 @@ import ( fakereplicationv1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/replication/v1/fake" replicationv2alpha1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/replication/v2alpha1" fakereplicationv2alpha1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/replication/v2alpha1/fake" + schedulerv1alpha1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/scheduler/v1alpha1" + fakeschedulerv1alpha1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/scheduler/v1alpha1/fake" storagev1alpha "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/storage/v1alpha" fakestoragev1alpha "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/storage/v1alpha/fake" "k8s.io/apimachinery/pkg/runtime" @@ -132,6 +134,11 @@ func (c *Clientset) ReplicationV2alpha1() replicationv2alpha1.ReplicationV2alpha return &fakereplicationv2alpha1.FakeReplicationV2alpha1{Fake: &c.Fake} } +// SchedulerV1alpha1 retrieves the SchedulerV1alpha1Client +func (c *Clientset) SchedulerV1alpha1() schedulerv1alpha1.SchedulerV1alpha1Interface { + return &fakeschedulerv1alpha1.FakeSchedulerV1alpha1{Fake: &c.Fake} +} + // StorageV1alpha retrieves the StorageV1alphaClient func (c *Clientset) StorageV1alpha() storagev1alpha.StorageV1alphaInterface { return &fakestoragev1alpha.FakeStorageV1alpha{Fake: &c.Fake} diff --git a/pkg/generated/clientset/versioned/fake/register.go b/pkg/generated/clientset/versioned/fake/register.go index 7d37d74c5..c8385285f 100644 --- a/pkg/generated/clientset/versioned/fake/register.go +++ b/pkg/generated/clientset/versioned/fake/register.go @@ -30,6 +30,7 @@ import ( mlv1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/ml/v1alpha1" replicationv1 "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" replicationv2alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/replication/v2alpha1" + schedulerv1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1" storagev1alpha "github.com/arangodb/kube-arangodb/pkg/apis/storage/v1alpha" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" @@ -49,6 +50,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ mlv1alpha1.AddToScheme, replicationv1.AddToScheme, replicationv2alpha1.AddToScheme, + schedulerv1alpha1.AddToScheme, storagev1alpha.AddToScheme, } diff --git a/pkg/generated/clientset/versioned/scheme/register.go b/pkg/generated/clientset/versioned/scheme/register.go index c5456d54a..ddd5006c1 100644 --- a/pkg/generated/clientset/versioned/scheme/register.go +++ b/pkg/generated/clientset/versioned/scheme/register.go @@ -30,6 +30,7 @@ import ( mlv1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/ml/v1alpha1" replicationv1 "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" replicationv2alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/replication/v2alpha1" + schedulerv1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1" storagev1alpha "github.com/arangodb/kube-arangodb/pkg/apis/storage/v1alpha" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" @@ -49,6 +50,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ mlv1alpha1.AddToScheme, replicationv1.AddToScheme, replicationv2alpha1.AddToScheme, + schedulerv1alpha1.AddToScheme, storagev1alpha.AddToScheme, } diff --git a/pkg/generated/clientset/versioned/typed/scheduler/v1alpha1/doc.go b/pkg/generated/clientset/versioned/typed/scheduler/v1alpha1/doc.go new file mode 100644 index 000000000..f45dab6c5 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/scheduler/v1alpha1/doc.go @@ -0,0 +1,24 @@ +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/pkg/generated/clientset/versioned/typed/scheduler/v1alpha1/fake/doc.go b/pkg/generated/clientset/versioned/typed/scheduler/v1alpha1/fake/doc.go new file mode 100644 index 000000000..cc487d814 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/scheduler/v1alpha1/fake/doc.go @@ -0,0 +1,24 @@ +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/pkg/generated/clientset/versioned/typed/scheduler/v1alpha1/fake/fake_scheduler_client.go b/pkg/generated/clientset/versioned/typed/scheduler/v1alpha1/fake/fake_scheduler_client.go new file mode 100644 index 000000000..b1827faaf --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/scheduler/v1alpha1/fake/fake_scheduler_client.go @@ -0,0 +1,39 @@ +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeSchedulerV1alpha1 struct { + *testing.Fake +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeSchedulerV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/generated/clientset/versioned/typed/scheduler/v1alpha1/generated_expansion.go b/pkg/generated/clientset/versioned/typed/scheduler/v1alpha1/generated_expansion.go new file mode 100644 index 000000000..74f850aac --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/scheduler/v1alpha1/generated_expansion.go @@ -0,0 +1,23 @@ +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 diff --git a/pkg/generated/clientset/versioned/typed/scheduler/v1alpha1/scheduler_client.go b/pkg/generated/clientset/versioned/typed/scheduler/v1alpha1/scheduler_client.go new file mode 100644 index 000000000..f80279a18 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/scheduler/v1alpha1/scheduler_client.go @@ -0,0 +1,106 @@ +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "net/http" + + v1alpha1 "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1" + "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type SchedulerV1alpha1Interface interface { + RESTClient() rest.Interface +} + +// SchedulerV1alpha1Client is used to interact with features provided by the scheduler.arangodb.com group. +type SchedulerV1alpha1Client struct { + restClient rest.Interface +} + +// NewForConfig creates a new SchedulerV1alpha1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*SchedulerV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new SchedulerV1alpha1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*SchedulerV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &SchedulerV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new SchedulerV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *SchedulerV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new SchedulerV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *SchedulerV1alpha1Client { + return &SchedulerV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *SchedulerV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/util/affinity/affinity.go b/pkg/util/affinity/affinity.go new file mode 100644 index 000000000..2df7dde3f --- /dev/null +++ b/pkg/util/affinity/affinity.go @@ -0,0 +1,209 @@ +// +// DISCLAIMER +// +// Copyright 2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package affinity + +import core "k8s.io/api/core/v1" + +func Merge(a, b *core.Affinity) *core.Affinity { + if a == nil && b == nil { + return nil + } + + if a == nil { + return b.DeepCopy() + } + + if b == nil { + return a.DeepCopy() + } + + return Optional(&core.Affinity{ + PodAntiAffinity: OptionalPodAntiAffinity(MergePodAntiAffinity(a.PodAntiAffinity, b.PodAntiAffinity)), + PodAffinity: OptionalPodAffinity(MergePodAffinity(a.PodAffinity, b.PodAffinity)), + NodeAffinity: OptionalNodeAffinity(MergeNodeAffinity(a.NodeAffinity, b.NodeAffinity)), + }) +} + +func Optional(a *core.Affinity) *core.Affinity { + if a.PodAntiAffinity == nil && a.NodeAffinity == nil && a.PodAffinity == nil { + return nil + } + + return a +} + +func MergePodAffinity(a, b *core.PodAffinity) *core.PodAffinity { + if a == nil && b == nil { + return nil + } + + if a == nil { + return b.DeepCopy() + } + + if b == nil { + return a.DeepCopy() + } + + n := a.DeepCopy() + + n.PreferredDuringSchedulingIgnoredDuringExecution = append(n.PreferredDuringSchedulingIgnoredDuringExecution, + b.PreferredDuringSchedulingIgnoredDuringExecution...) + + n.RequiredDuringSchedulingIgnoredDuringExecution = append(n.RequiredDuringSchedulingIgnoredDuringExecution, + b.RequiredDuringSchedulingIgnoredDuringExecution...) + + return n +} + +func OptionalPodAffinity(a *core.PodAffinity) *core.PodAffinity { + if a == nil { + return nil + } + + if len(a.RequiredDuringSchedulingIgnoredDuringExecution) > 0 || len(a.PreferredDuringSchedulingIgnoredDuringExecution) > 0 { + return a + } + + return nil +} + +func MergePodAntiAffinity(a, b *core.PodAntiAffinity) *core.PodAntiAffinity { + if a == nil && b == nil { + return nil + } + + if a == nil { + return b.DeepCopy() + } + + if b == nil { + return a.DeepCopy() + } + + n := a.DeepCopy() + + n.PreferredDuringSchedulingIgnoredDuringExecution = append(n.PreferredDuringSchedulingIgnoredDuringExecution, + b.PreferredDuringSchedulingIgnoredDuringExecution...) + + n.RequiredDuringSchedulingIgnoredDuringExecution = append(n.RequiredDuringSchedulingIgnoredDuringExecution, + b.RequiredDuringSchedulingIgnoredDuringExecution...) + + return n +} + +func OptionalPodAntiAffinity(a *core.PodAntiAffinity) *core.PodAntiAffinity { + if a == nil { + return nil + } + + if len(a.RequiredDuringSchedulingIgnoredDuringExecution) > 0 || len(a.PreferredDuringSchedulingIgnoredDuringExecution) > 0 { + return a + } + + return nil +} + +func MergeNodeAffinity(a, b *core.NodeAffinity) *core.NodeAffinity { + if a == nil && b == nil { + return nil + } + + if a == nil { + return b.DeepCopy() + } + + if b == nil { + return a.DeepCopy() + } + + n := a.DeepCopy() + + n.PreferredDuringSchedulingIgnoredDuringExecution = append(n.PreferredDuringSchedulingIgnoredDuringExecution, + b.PreferredDuringSchedulingIgnoredDuringExecution...) + + n.RequiredDuringSchedulingIgnoredDuringExecution = MergeNodeSelector(n.RequiredDuringSchedulingIgnoredDuringExecution, b.RequiredDuringSchedulingIgnoredDuringExecution) + + return n +} + +func MergeNodeSelector(a, b *core.NodeSelector) *core.NodeSelector { + if a == nil && b == nil { + return nil + } + + if a == nil { + return b.DeepCopy() + } + + if b == nil { + return a.DeepCopy() + } + + if len(a.NodeSelectorTerms) == 0 && len(b.NodeSelectorTerms) == 0 { + return nil + } + + if len(a.NodeSelectorTerms) == 0 { + return b.DeepCopy() + } + + if len(b.NodeSelectorTerms) == 0 { + return a.DeepCopy() + } + + current := a.DeepCopy() + new := b.DeepCopy() + + for id := range current.NodeSelectorTerms { + term := current.NodeSelectorTerms[id] + for _, newTerm := range new.NodeSelectorTerms { + if len(newTerm.MatchExpressions) != 0 { + term.MatchExpressions = append(term.MatchExpressions, newTerm.MatchExpressions...) + } + if len(newTerm.MatchFields) != 0 { + term.MatchFields = append(term.MatchFields, newTerm.MatchFields...) + } + } + + current.NodeSelectorTerms[id] = term + } + + return current +} + +func OptionalNodeAffinity(a *core.NodeAffinity) *core.NodeAffinity { + if a == nil { + return nil + } + + if len(a.PreferredDuringSchedulingIgnoredDuringExecution) > 0 { + return a + } + + if s := a.RequiredDuringSchedulingIgnoredDuringExecution; s != nil { + if len(s.NodeSelectorTerms) > 0 { + return a + } + } + + return nil +} diff --git a/pkg/util/k8sutil/container.go b/pkg/util/k8sutil/container/container.go similarity index 80% rename from pkg/util/k8sutil/container.go rename to pkg/util/k8sutil/container/container.go index f87bc8aa3..a764de9a7 100644 --- a/pkg/util/k8sutil/container.go +++ b/pkg/util/k8sutil/container/container.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,9 +18,22 @@ // Copyright holder is ArangoDB GmbH, Cologne, Germany // -package k8sutil +package container -import core "k8s.io/api/core/v1" +import ( + core "k8s.io/api/core/v1" +) + +// GetContainerIDByName returns the container id in the given list with the given name. +// Returns -1 if not found. +func GetContainerIDByName(containers []core.Container, name string) int { + for id, c := range containers { + if c.Name == name { + return id + } + } + return -1 +} // GetContainerByName returns the container in the given pod with the given name. // Returns false if not found. @@ -95,3 +108,15 @@ func IsResourceRequirementsChanged(wanted, given core.ResourceRequirements) bool return checkList(wanted.Limits, given.Limits) || checkList(wanted.Requests, given.Requests) } + +// IsContainerFailed returns true if the arangodb container +// has terminated wih a non-zero exit code. +func IsContainerFailed(container *core.ContainerStatus) bool { + if c := container.State.Terminated; c != nil { + if c.ExitCode != 0 { + return true + } + } + + return false +} diff --git a/pkg/util/k8sutil/images.go b/pkg/util/k8sutil/images.go index 1de38fd4b..b639ea5c2 100644 --- a/pkg/util/k8sutil/images.go +++ b/pkg/util/k8sutil/images.go @@ -25,8 +25,8 @@ import ( core "k8s.io/api/core/v1" + schedulerContainerResourcesApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/container/resources" shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" - sharedApi "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1" "github.com/arangodb/kube-arangodb/pkg/util/errors" ) @@ -64,8 +64,8 @@ func GetArangoDBImageIDFromPod(pod *core.Pod) (string, error) { } // GetImageDetails Returns latest defined Image details -func GetImageDetails(images ...*sharedApi.Image) *sharedApi.Image { - var out *sharedApi.Image +func GetImageDetails(images ...*schedulerContainerResourcesApi.Image) *schedulerContainerResourcesApi.Image { + var out *schedulerContainerResourcesApi.Image for _, image := range images { if image != nil { @@ -75,42 +75,3 @@ func GetImageDetails(images ...*sharedApi.Image) *sharedApi.Image { return out } - -// InjectImageDetails injects image details into the Pod definition -func InjectImageDetails(image *sharedApi.Image, pod *core.PodTemplateSpec, containers ...*core.Container) error { - if image == nil { - return errors.Errorf("Image not found") - } else if err := image.Validate(); err != nil { - return errors.Wrapf(err, "Unable to validate image") - } - - for _, secret := range image.PullSecrets { - if HasImagePullSecret(pod.Spec.ImagePullSecrets, secret) { - continue - } - - pod.Spec.ImagePullSecrets = append(pod.Spec.ImagePullSecrets, core.LocalObjectReference{ - Name: secret, - }) - } - - for _, container := range containers { - container.Image = *image.Image - - if ps := image.PullPolicy; ps != nil { - container.ImagePullPolicy = *ps - } - } - - return nil -} - -func HasImagePullSecret(secrets []core.LocalObjectReference, secret string) bool { - for _, sec := range secrets { - if sec.Name == secret { - return true - } - } - - return false -} diff --git a/pkg/util/k8sutil/pods.go b/pkg/util/k8sutil/pods.go index 2795948f8..1b39a40e4 100644 --- a/pkg/util/k8sutil/pods.go +++ b/pkg/util/k8sutil/pods.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -35,8 +35,9 @@ import ( "k8s.io/apimachinery/pkg/util/json" api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" + schedulerContainerApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/container" + schedulerContainerResourcesApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/container/resources" shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" - sharedApi "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1" "github.com/arangodb/kube-arangodb/pkg/deployment/features" "github.com/arangodb/kube-arangodb/pkg/deployment/patch" "github.com/arangodb/kube-arangodb/pkg/handlers/utils" @@ -44,7 +45,6 @@ import ( "github.com/arangodb/kube-arangodb/pkg/util/constants" "github.com/arangodb/kube-arangodb/pkg/util/errors" "github.com/arangodb/kube-arangodb/pkg/util/globals" - "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/envs" podv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/pod/v1" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/interfaces" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/kerrors" @@ -265,18 +265,6 @@ func IsPodFailed(pod *core.Pod, coreContainers utils.StringList) bool { return true } -// IsContainerFailed returns true if the arangodb container -// has terminated wih a non-zero exit code. -func IsContainerFailed(container *core.ContainerStatus) bool { - if c := container.State.Terminated; c != nil { - if c.ExitCode != 0 { - return true - } - } - - return false -} - // IsPodScheduled returns true if the pod has been scheduled. func IsPodScheduled(pod *core.Pod) bool { condition := getPodCondition(&pod.Status, core.PodScheduled) @@ -766,63 +754,10 @@ func GetFinalizers(spec api.ServerGroupSpec, group api.ServerGroup) []string { return finalizers } -func InjectPodTemplate(spec *sharedApi.PodTemplate, pod *core.PodTemplateSpec) error { - if scheduling := spec.GetScheduling(); scheduling != nil { - pod.Spec.Tolerations = scheduling.GetTolerations().DeepCopy() - pod.Spec.Affinity = scheduling.GetAffinity().DeepCopy() - pod.Spec.NodeSelector = util.CopyFullMap(scheduling.GetNodeSelector()) - pod.Spec.SchedulerName = spec.GetSchedulerName() - } - - if namespace := spec.GetContainerNamespace(); namespace != nil { - pod.Spec.HostNetwork = namespace.GetHostNetwork() - pod.Spec.HostPID = namespace.GetHostPID() - pod.Spec.HostIPC = namespace.GetHostIPC() - pod.Spec.ShareProcessNamespace = util.NewType(util.TypeOrDefault(namespace.GetShareProcessNamespace(), false)) - } - - if security := spec.GetSecurityPod(); security != nil { - pod.Spec.SecurityContext = security.PodSecurityContext.DeepCopy() - } - - return nil -} - -func InjectContainersTemplate(spec *sharedApi.ContainerTemplate, pod *core.PodTemplateSpec, containers ...*core.Container) error { - for _, container := range containers { - if err := InjectContainerTemplate(spec, pod, container); err != nil { - return err - } - } - - return nil -} - -func InjectContainerTemplate(spec *sharedApi.ContainerTemplate, pod *core.PodTemplateSpec, container *core.Container) error { - if err := InjectImageDetails(spec.GetImage(), pod, container); err != nil { - return err - } - - if res := spec.GetResources(); res != nil { - container.Resources = util.TypeOrDefault(res.GetResources()) - } - - if security := spec.GetSecurityContainer(); security != nil { - container.SecurityContext = security.SecurityContext.DeepCopy() - } - - if environments := spec.GetEnvironments(); environments != nil { - container.Env = envs.MergeEnvs(container.Env, environments.Env...) - container.EnvFrom = envs.MergeEnvFrom(container.EnvFrom, environments.EnvFrom...) - } - - return nil -} - -func CreateDefaultContainerTemplate(image *sharedApi.Image) *sharedApi.ContainerTemplate { - return &sharedApi.ContainerTemplate{ +func CreateDefaultContainerTemplate(image *schedulerContainerResourcesApi.Image) *schedulerContainerApi.Container { + return &schedulerContainerApi.Container{ Image: image.DeepCopy(), - Resources: &sharedApi.Resources{ + Resources: &schedulerContainerResourcesApi.Resources{ Resources: &core.ResourceRequirements{ Requests: core.ResourceList{ core.ResourceCPU: resource.MustParse("100m"), @@ -834,7 +769,7 @@ func CreateDefaultContainerTemplate(image *sharedApi.Image) *sharedApi.Container }, }, }, - SecurityContainer: &sharedApi.SecurityContainer{ + Security: &schedulerContainerResourcesApi.Security{ SecurityContext: &core.SecurityContext{ RunAsUser: util.NewType[int64](shared.DefaultRunAsUser), RunAsGroup: util.NewType[int64](shared.DefaultRunAsGroup), diff --git a/pkg/util/refs.go b/pkg/util/refs.go index e426f2be7..002a47c31 100644 --- a/pkg/util/refs.go +++ b/pkg/util/refs.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -46,6 +46,15 @@ func TypeOrDefault[T interface{}](input *T, defaultValue ...T) T { return *input } +// WithDefault returns generic default value for type T if in is nil +func WithDefault[T interface{}](in *T) T { + if in == nil { + return Default[T]() + } + + return *in +} + // Default returns generic default value for type T func Default[T interface{}]() T { var d T