From 623db31086ddced812fc7bcad142635d0e8aa1c3 Mon Sep 17 00:00:00 2001 From: jwierzbo Date: Wed, 13 Dec 2023 15:09:14 +0100 Subject: [PATCH 1/7] Jobs templates --- docs/api/ArangoMLExtension.V1Alpha1.md | 294 ++++++ pkg/apis/ml/v1alpha1/extension_spec.go | 23 +- ...spec_init_job.go => extension_spec_job.go} | 43 +- pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go | 85 +- .../crds/ml-extension.schema.generated.yaml | 990 +++++++++++++++++- 5 files changed, 1397 insertions(+), 38 deletions(-) rename pkg/apis/ml/v1alpha1/{extension_spec_init_job.go => extension_spec_job.go} (56%) diff --git a/docs/api/ArangoMLExtension.V1Alpha1.md b/docs/api/ArangoMLExtension.V1Alpha1.md index 0ded09bff..ed518e48b 100644 --- a/docs/api/ArangoMLExtension.V1Alpha1.md +++ b/docs/api/ArangoMLExtension.V1Alpha1.md @@ -451,6 +451,300 @@ Links: *** +### .spec.jobsTemplates.prediction.affinity + +Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L37) + +Affinity defines scheduling constraints for workload + +Links: +* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity) + +*** + +### .spec.jobsTemplates.prediction.hostIPC + +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L33) + +HostIPC defines to use the host's ipc namespace. + +Default Value: `false` + +*** + +### .spec.jobsTemplates.prediction.hostNetwork + +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L27) + +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. + +Default Value: `false` + +*** + +### .spec.jobsTemplates.prediction.hostPID + +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L30) + +HostPID define to use the host's pid namespace. + +Default Value: `false` + +*** + +### .spec.jobsTemplates.prediction.image + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L31) + +Image define image details + +*** + +### .spec.jobsTemplates.prediction.nodeSelector + +Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L32) + +NodeSelector is a selector that must be true for the workload to fit on a node. + +Links: +* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) + +*** + +### .spec.jobsTemplates.prediction.podSecurityContext + +Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_pod.go#L29) + +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.prediction.pullPolicy + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L35) + +PullPolicy define Image pull policy + +Default Value: `IfNotPresent` + +*** + +### .spec.jobsTemplates.prediction.pullSecrets + +Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L38) + +PullSecrets define Secrets used to pull Image from registry + +*** + +### .spec.jobsTemplates.prediction.resources + +Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/resources.go#L34) + +Resources holds resource requests & limits for container + +Links: +* [Documentation of core.ResourceRequirements](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/#resourcerequirements-v1-core) + +*** + +### .spec.jobsTemplates.prediction.schedulerName + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L47) + +SchedulerName specifies, the pod will be dispatched by specified scheduler. +If not specified, the pod will be dispatched by default scheduler. + +Default Value: `""` + +*** + +### .spec.jobsTemplates.prediction.securityContext + +Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_container.go#L29) + +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.prediction.shareProcessNamespace + +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L39) + +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. + +Default Value: `false` + +*** + +### .spec.jobsTemplates.prediction.tolerations + +Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L42) + +Tolerations defines tolerations + +Links: +* [Kubernetes docs](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) + +*** + +### .spec.jobsTemplates.training.affinity + +Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L37) + +Affinity defines scheduling constraints for workload + +Links: +* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity) + +*** + +### .spec.jobsTemplates.training.hostIPC + +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L33) + +HostIPC defines to use the host's ipc namespace. + +Default Value: `false` + +*** + +### .spec.jobsTemplates.training.hostNetwork + +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L27) + +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. + +Default Value: `false` + +*** + +### .spec.jobsTemplates.training.hostPID + +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L30) + +HostPID define to use the host's pid namespace. + +Default Value: `false` + +*** + +### .spec.jobsTemplates.training.image + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L31) + +Image define image details + +*** + +### .spec.jobsTemplates.training.nodeSelector + +Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L32) + +NodeSelector is a selector that must be true for the workload to fit on a node. + +Links: +* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) + +*** + +### .spec.jobsTemplates.training.podSecurityContext + +Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_pod.go#L29) + +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.training.pullPolicy + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L35) + +PullPolicy define Image pull policy + +Default Value: `IfNotPresent` + +*** + +### .spec.jobsTemplates.training.pullSecrets + +Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L38) + +PullSecrets define Secrets used to pull Image from registry + +*** + +### .spec.jobsTemplates.training.resources + +Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/resources.go#L34) + +Resources holds resource requests & limits for container + +Links: +* [Documentation of core.ResourceRequirements](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/#resourcerequirements-v1-core) + +*** + +### .spec.jobsTemplates.training.schedulerName + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L47) + +SchedulerName specifies, the pod will be dispatched by specified scheduler. +If not specified, the pod will be dispatched by default scheduler. + +Default Value: `""` + +*** + +### .spec.jobsTemplates.training.securityContext + +Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_container.go#L29) + +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.training.shareProcessNamespace + +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L39) + +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. + +Default Value: `false` + +*** + +### .spec.jobsTemplates.training.tolerations + +Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L42) + +Tolerations defines tolerations + +Links: +* [Kubernetes docs](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) + +*** + ### .spec.metadataService.local.arangoMLFeatureStore Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/extension_spec_metadata_service.go#L65) diff --git a/pkg/apis/ml/v1alpha1/extension_spec.go b/pkg/apis/ml/v1alpha1/extension_spec.go index 4b041f84b..37118d2df 100644 --- a/pkg/apis/ml/v1alpha1/extension_spec.go +++ b/pkg/apis/ml/v1alpha1/extension_spec.go @@ -36,11 +36,14 @@ type ArangoMLExtensionSpec struct { // Image defines default image used for the extension *sharedApi.Image `json:",inline"` - // ArangoMLExtensionSpecInit define Init job specification - Init *ArangoMLExtensionSpecInit `json:"init,omitempty"` + // ArangoMLExtensionTemplateSpec define Init job specification + Init *ArangoMLExtensionTemplateSpec `json:"init,omitempty"` // Deployment specifies how the ML extension will be deployed into cluster Deployment *ArangoMLExtensionSpecDeployment `json:"deployment,omitempty"` + + // JobsTemplates defines templates for jobs + JobsTemplates *ArangoMLJobsTemplates `json:"jobsTemplates,omitempty"` } func (a *ArangoMLExtensionSpec) GetMetadataService() *ArangoMLExtensionSpecMetadataService { @@ -59,7 +62,7 @@ func (a *ArangoMLExtensionSpec) GetImage() *sharedApi.Image { return a.Image } -func (a *ArangoMLExtensionSpec) GetInit() *ArangoMLExtensionSpecInit { +func (a *ArangoMLExtensionSpec) GetInit() *ArangoMLExtensionTemplateSpec { if a == nil || a.Init == nil { return nil } @@ -75,11 +78,18 @@ func (a *ArangoMLExtensionSpec) GetStorage() *sharedApi.Object { return a.Storage } -func (s *ArangoMLExtensionSpec) GetDeployment() *ArangoMLExtensionSpecDeployment { - if s == nil || s.Deployment == nil { +func (a *ArangoMLExtensionSpec) GetDeployment() *ArangoMLExtensionSpecDeployment { + if a == nil || a.Deployment == nil { + return nil + } + return a.Deployment +} + +func (a *ArangoMLExtensionSpec) GetJobsTemplates() *ArangoMLJobsTemplates { + if a == nil || a.JobsTemplates == nil { return nil } - return s.Deployment + return a.JobsTemplates } func (a *ArangoMLExtensionSpec) Validate() error { @@ -94,5 +104,6 @@ func (a *ArangoMLExtensionSpec) Validate() error { shared.PrefixResourceErrors("init", a.GetInit().Validate()), shared.ValidateAnyNotNil(".image or .init.image needs to be specified", a.GetImage(), a.GetInit().GetContainerTemplate().GetImage()), shared.PrefixResourceErrors("deployment", a.GetDeployment().Validate()), + shared.PrefixResourceErrors("jobsTemplates", a.GetJobsTemplates().Validate()), )) } diff --git a/pkg/apis/ml/v1alpha1/extension_spec_init_job.go b/pkg/apis/ml/v1alpha1/extension_spec_job.go similarity index 56% rename from pkg/apis/ml/v1alpha1/extension_spec_init_job.go rename to pkg/apis/ml/v1alpha1/extension_spec_job.go index 4e2473552..82a4af02c 100644 --- a/pkg/apis/ml/v1alpha1/extension_spec_init_job.go +++ b/pkg/apis/ml/v1alpha1/extension_spec_job.go @@ -25,7 +25,42 @@ import ( sharedApi "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1" ) -type ArangoMLExtensionSpecInit struct { +type ArangoMLJobsTemplates struct { + // Prediction defines template for the prediction job + Prediction *ArangoMLExtensionTemplateSpec `json:"prediction,omitempty"` + + // Training defines template for the training job + Training *ArangoMLExtensionTemplateSpec `json:"training,omitempty"` +} + +func (j *ArangoMLJobsTemplates) GetPrediction() *ArangoMLExtensionTemplateSpec { + if j == nil { + return nil + } + + return j.Prediction +} + +func (j *ArangoMLJobsTemplates) GetTraining() *ArangoMLExtensionTemplateSpec { + if j == nil { + return nil + } + + return j.Training +} + +func (j *ArangoMLJobsTemplates) Validate() error { + if j == nil { + return nil + } + + return shared.WithErrors( + j.GetPrediction().Validate(), + j.GetTraining().Validate(), + ) +} + +type ArangoMLExtensionTemplateSpec struct { // PodTemplate keeps the information about Pod configuration *sharedApi.PodTemplate `json:",inline"` @@ -33,7 +68,7 @@ type ArangoMLExtensionSpecInit struct { *sharedApi.ContainerTemplate `json:",inline"` } -func (a *ArangoMLExtensionSpecInit) GetPodTemplate() *sharedApi.PodTemplate { +func (a *ArangoMLExtensionTemplateSpec) GetPodTemplate() *sharedApi.PodTemplate { if a == nil { return nil } @@ -41,7 +76,7 @@ func (a *ArangoMLExtensionSpecInit) GetPodTemplate() *sharedApi.PodTemplate { return a.PodTemplate } -func (a *ArangoMLExtensionSpecInit) GetContainerTemplate() *sharedApi.ContainerTemplate { +func (a *ArangoMLExtensionTemplateSpec) GetContainerTemplate() *sharedApi.ContainerTemplate { if a == nil { return nil } @@ -49,7 +84,7 @@ func (a *ArangoMLExtensionSpecInit) GetContainerTemplate() *sharedApi.ContainerT return a.ContainerTemplate } -func (a *ArangoMLExtensionSpecInit) Validate() error { +func (a *ArangoMLExtensionTemplateSpec) Validate() error { if a == nil { return nil } diff --git a/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go index 62bf82ff8..52f0ba01f 100644 --- a/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go @@ -344,7 +344,7 @@ func (in *ArangoMLExtensionSpec) DeepCopyInto(out *ArangoMLExtensionSpec) { } if in.Init != nil { in, out := &in.Init, &out.Init - *out = new(ArangoMLExtensionSpecInit) + *out = new(ArangoMLExtensionTemplateSpec) (*in).DeepCopyInto(*out) } if in.Deployment != nil { @@ -352,6 +352,11 @@ func (in *ArangoMLExtensionSpec) DeepCopyInto(out *ArangoMLExtensionSpec) { *out = new(ArangoMLExtensionSpecDeployment) (*in).DeepCopyInto(*out) } + if in.JobsTemplates != nil { + in, out := &in.JobsTemplates, &out.JobsTemplates + *out = new(ArangoMLJobsTemplates) + (*in).DeepCopyInto(*out) + } return } @@ -458,32 +463,6 @@ func (in *ArangoMLExtensionSpecDeploymentService) DeepCopy() *ArangoMLExtensionS return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ArangoMLExtensionSpecInit) DeepCopyInto(out *ArangoMLExtensionSpecInit) { - *out = *in - if in.PodTemplate != nil { - in, out := &in.PodTemplate, &out.PodTemplate - *out = new(sharedv1.PodTemplate) - (*in).DeepCopyInto(*out) - } - if in.ContainerTemplate != nil { - in, out := &in.ContainerTemplate, &out.ContainerTemplate - *out = new(sharedv1.ContainerTemplate) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoMLExtensionSpecInit. -func (in *ArangoMLExtensionSpecInit) DeepCopy() *ArangoMLExtensionSpecInit { - if in == nil { - return nil - } - out := new(ArangoMLExtensionSpecInit) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ArangoMLExtensionSpecMetadataService) DeepCopyInto(out *ArangoMLExtensionSpecMetadataService) { *out = *in @@ -632,6 +611,58 @@ func (in *ArangoMLExtensionStatusMetadataServiceLocal) DeepCopy() *ArangoMLExten return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoMLExtensionTemplateSpec) DeepCopyInto(out *ArangoMLExtensionTemplateSpec) { + *out = *in + if in.PodTemplate != nil { + in, out := &in.PodTemplate, &out.PodTemplate + *out = new(sharedv1.PodTemplate) + (*in).DeepCopyInto(*out) + } + if in.ContainerTemplate != nil { + in, out := &in.ContainerTemplate, &out.ContainerTemplate + *out = new(sharedv1.ContainerTemplate) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoMLExtensionTemplateSpec. +func (in *ArangoMLExtensionTemplateSpec) DeepCopy() *ArangoMLExtensionTemplateSpec { + if in == nil { + return nil + } + out := new(ArangoMLExtensionTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoMLJobsTemplates) DeepCopyInto(out *ArangoMLJobsTemplates) { + *out = *in + if in.Prediction != nil { + in, out := &in.Prediction, &out.Prediction + *out = new(ArangoMLExtensionTemplateSpec) + (*in).DeepCopyInto(*out) + } + if in.Training != nil { + in, out := &in.Training, &out.Training + *out = new(ArangoMLExtensionTemplateSpec) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoMLJobsTemplates. +func (in *ArangoMLJobsTemplates) DeepCopy() *ArangoMLJobsTemplates { + if in == nil { + return nil + } + out := new(ArangoMLJobsTemplates) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ArangoMLStorage) DeepCopyInto(out *ArangoMLStorage) { *out = *in diff --git a/pkg/crd/crds/ml-extension.schema.generated.yaml b/pkg/crd/crds/ml-extension.schema.generated.yaml index 61455a16c..780085483 100644 --- a/pkg/crd/crds/ml-extension.schema.generated.yaml +++ b/pkg/crd/crds/ml-extension.schema.generated.yaml @@ -705,7 +705,7 @@ v1alpha1: description: Image define image details type: string init: - description: ArangoMLExtensionSpecInit define Init job specification + description: ArangoMLExtensionTemplateSpec define Init job specification properties: affinity: description: Affinity defines scheduling constraints for workload @@ -1196,6 +1196,994 @@ v1alpha1: type: object type: array type: object + jobsTemplates: + description: JobsTemplates defines templates for jobs + properties: + prediction: + description: Prediction defines template for the prediction job + properties: + affinity: + description: Affinity defines scheduling constraints for workload + properties: + nodeAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + preference: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchFields: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + properties: + nodeSelectorTerms: + items: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchFields: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + type: object + type: array + type: object + type: object + podAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + podAffinityTerm: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: + type: string + type: array + topologyKey: + type: string + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + items: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: + type: string + type: array + topologyKey: + type: string + type: object + type: array + type: object + podAntiAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + podAffinityTerm: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: + type: string + type: array + topologyKey: + type: string + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + items: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: + type: string + type: array + topologyKey: + type: string + type: object + type: array + 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 + image: + description: Image define image details + type: string + 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 + type: integer + fsGroupChangePolicy: + type: string + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: + type: string + role: + type: string + type: + type: string + user: + type: string + type: object + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + type: object + supplementalGroups: + items: + format: int64 + type: integer + type: array + sysctls: + items: + properties: + name: + type: string + value: + type: string + type: object + type: array + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + 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: + limits: + additionalProperties: + type: string + type: object + requests: + additionalProperties: + type: string + 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 + capabilities: + properties: + add: + items: + type: string + type: array + drop: + items: + type: string + type: array + type: object + privileged: + type: boolean + procMount: + type: string + readOnlyRootFilesystem: + type: boolean + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: + type: string + role: + type: string + type: + type: string + user: + type: string + type: object + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + type: object + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + type: string + 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: + type: string + key: + type: string + operator: + type: string + tolerationSeconds: + format: int64 + type: integer + value: + type: string + type: object + type: array + type: object + training: + description: Training defines template for the training job + properties: + affinity: + description: Affinity defines scheduling constraints for workload + properties: + nodeAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + preference: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchFields: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + properties: + nodeSelectorTerms: + items: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchFields: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + type: object + type: array + type: object + type: object + podAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + podAffinityTerm: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: + type: string + type: array + topologyKey: + type: string + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + items: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: + type: string + type: array + topologyKey: + type: string + type: object + type: array + type: object + podAntiAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + podAffinityTerm: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: + type: string + type: array + topologyKey: + type: string + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + items: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: + type: string + type: array + topologyKey: + type: string + type: object + type: array + 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 + image: + description: Image define image details + type: string + 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 + type: integer + fsGroupChangePolicy: + type: string + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: + type: string + role: + type: string + type: + type: string + user: + type: string + type: object + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + type: object + supplementalGroups: + items: + format: int64 + type: integer + type: array + sysctls: + items: + properties: + name: + type: string + value: + type: string + type: object + type: array + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + 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: + limits: + additionalProperties: + type: string + type: object + requests: + additionalProperties: + type: string + 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 + capabilities: + properties: + add: + items: + type: string + type: array + drop: + items: + type: string + type: array + type: object + privileged: + type: boolean + procMount: + type: string + readOnlyRootFilesystem: + type: boolean + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: + type: string + role: + type: string + type: + type: string + user: + type: string + type: object + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + type: object + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + type: string + 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: + type: string + key: + type: string + operator: + type: string + tolerationSeconds: + format: int64 + type: integer + value: + type: string + type: object + type: array + type: object + type: object metadataService: description: MetadataService keeps the MetadataService configuration properties: From 85ce4556e811b3bcf03e1a2b3f0f6a3b6cd7f287 Mon Sep 17 00:00:00 2001 From: jwierzbo Date: Thu, 14 Dec 2023 23:26:47 +0100 Subject: [PATCH 2/7] ML Jobs labels --- docs/api/ArangoMLExtension.V1Alpha1.md | 56 +- pkg/apis/ml/v1alpha1/batchjob.go | 66 +- pkg/apis/ml/v1alpha1/batchjob_spec.go | 4 + pkg/apis/ml/v1alpha1/cronjob_spec.go | 5 + pkg/apis/ml/v1alpha1/extension_spec_job.go | 32 +- pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go | 28 +- .../crds/ml-extension.schema.generated.yaml | 1754 +++++++++-------- pkg/util/constants/constants.go | 10 + 8 files changed, 1025 insertions(+), 930 deletions(-) diff --git a/docs/api/ArangoMLExtension.V1Alpha1.md b/docs/api/ArangoMLExtension.V1Alpha1.md index ed518e48b..cc6483734 100644 --- a/docs/api/ArangoMLExtension.V1Alpha1.md +++ b/docs/api/ArangoMLExtension.V1Alpha1.md @@ -451,7 +451,7 @@ Links: *** -### .spec.jobsTemplates.prediction.affinity +### .spec.jobsTemplates.prediction.\.affinity Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L37) @@ -462,7 +462,7 @@ Links: *** -### .spec.jobsTemplates.prediction.hostIPC +### .spec.jobsTemplates.prediction.\.hostIPC Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L33) @@ -472,7 +472,7 @@ Default Value: `false` *** -### .spec.jobsTemplates.prediction.hostNetwork +### .spec.jobsTemplates.prediction.\.hostNetwork Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L27) @@ -483,7 +483,7 @@ Default Value: `false` *** -### .spec.jobsTemplates.prediction.hostPID +### .spec.jobsTemplates.prediction.\.hostPID Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L30) @@ -493,7 +493,7 @@ Default Value: `false` *** -### .spec.jobsTemplates.prediction.image +### .spec.jobsTemplates.prediction.\.image Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L31) @@ -501,7 +501,7 @@ Image define image details *** -### .spec.jobsTemplates.prediction.nodeSelector +### .spec.jobsTemplates.prediction.\.nodeSelector Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L32) @@ -512,7 +512,7 @@ Links: *** -### .spec.jobsTemplates.prediction.podSecurityContext +### .spec.jobsTemplates.prediction.\.podSecurityContext Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_pod.go#L29) @@ -523,7 +523,7 @@ Links: *** -### .spec.jobsTemplates.prediction.pullPolicy +### .spec.jobsTemplates.prediction.\.pullPolicy Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L35) @@ -533,7 +533,7 @@ Default Value: `IfNotPresent` *** -### .spec.jobsTemplates.prediction.pullSecrets +### .spec.jobsTemplates.prediction.\.pullSecrets Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L38) @@ -541,7 +541,7 @@ PullSecrets define Secrets used to pull Image from registry *** -### .spec.jobsTemplates.prediction.resources +### .spec.jobsTemplates.prediction.\.resources Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/resources.go#L34) @@ -552,7 +552,7 @@ Links: *** -### .spec.jobsTemplates.prediction.schedulerName +### .spec.jobsTemplates.prediction.\.schedulerName Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L47) @@ -563,7 +563,7 @@ Default Value: `""` *** -### .spec.jobsTemplates.prediction.securityContext +### .spec.jobsTemplates.prediction.\.securityContext Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_container.go#L29) @@ -574,7 +574,7 @@ Links: *** -### .spec.jobsTemplates.prediction.shareProcessNamespace +### .spec.jobsTemplates.prediction.\.shareProcessNamespace Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L39) @@ -587,7 +587,7 @@ Default Value: `false` *** -### .spec.jobsTemplates.prediction.tolerations +### .spec.jobsTemplates.prediction.\.tolerations Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L42) @@ -598,7 +598,7 @@ Links: *** -### .spec.jobsTemplates.training.affinity +### .spec.jobsTemplates.training.\.affinity Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L37) @@ -609,7 +609,7 @@ Links: *** -### .spec.jobsTemplates.training.hostIPC +### .spec.jobsTemplates.training.\.hostIPC Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L33) @@ -619,7 +619,7 @@ Default Value: `false` *** -### .spec.jobsTemplates.training.hostNetwork +### .spec.jobsTemplates.training.\.hostNetwork Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L27) @@ -630,7 +630,7 @@ Default Value: `false` *** -### .spec.jobsTemplates.training.hostPID +### .spec.jobsTemplates.training.\.hostPID Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L30) @@ -640,7 +640,7 @@ Default Value: `false` *** -### .spec.jobsTemplates.training.image +### .spec.jobsTemplates.training.\.image Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L31) @@ -648,7 +648,7 @@ Image define image details *** -### .spec.jobsTemplates.training.nodeSelector +### .spec.jobsTemplates.training.\.nodeSelector Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L32) @@ -659,7 +659,7 @@ Links: *** -### .spec.jobsTemplates.training.podSecurityContext +### .spec.jobsTemplates.training.\.podSecurityContext Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_pod.go#L29) @@ -670,7 +670,7 @@ Links: *** -### .spec.jobsTemplates.training.pullPolicy +### .spec.jobsTemplates.training.\.pullPolicy Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L35) @@ -680,7 +680,7 @@ Default Value: `IfNotPresent` *** -### .spec.jobsTemplates.training.pullSecrets +### .spec.jobsTemplates.training.\.pullSecrets Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L38) @@ -688,7 +688,7 @@ PullSecrets define Secrets used to pull Image from registry *** -### .spec.jobsTemplates.training.resources +### .spec.jobsTemplates.training.\.resources Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/resources.go#L34) @@ -699,7 +699,7 @@ Links: *** -### .spec.jobsTemplates.training.schedulerName +### .spec.jobsTemplates.training.\.schedulerName Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L47) @@ -710,7 +710,7 @@ Default Value: `""` *** -### .spec.jobsTemplates.training.securityContext +### .spec.jobsTemplates.training.\.securityContext Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_container.go#L29) @@ -721,7 +721,7 @@ Links: *** -### .spec.jobsTemplates.training.shareProcessNamespace +### .spec.jobsTemplates.training.\.shareProcessNamespace Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L39) @@ -734,7 +734,7 @@ Default Value: `false` *** -### .spec.jobsTemplates.training.tolerations +### .spec.jobsTemplates.training.\.tolerations Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L42) diff --git a/pkg/apis/ml/v1alpha1/batchjob.go b/pkg/apis/ml/v1alpha1/batchjob.go index beebeea6a..78aaa9ef5 100644 --- a/pkg/apis/ml/v1alpha1/batchjob.go +++ b/pkg/apis/ml/v1alpha1/batchjob.go @@ -21,9 +21,13 @@ package v1alpha1 import ( + "strings" + meta "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/arangodb/kube-arangodb/pkg/apis/ml" + "github.com/arangodb/kube-arangodb/pkg/util/constants" + "github.com/arangodb/kube-arangodb/pkg/util/errors" ) // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -39,7 +43,7 @@ type ArangoMLBatchJobList struct { // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// ArangoMLBatchJob contains definition and status of the ArangoML BatchJob. +// ArangoMLBatchJob contains the definition and status of the ArangoML BatchJob. type ArangoMLBatchJob struct { meta.TypeMeta `json:",inline"` meta.ObjectMeta `json:"metadata,omitempty"` @@ -49,13 +53,13 @@ type ArangoMLBatchJob struct { } // AsOwner creates an OwnerReference for the given BatchJob -func (d *ArangoMLBatchJob) AsOwner() meta.OwnerReference { +func (a *ArangoMLBatchJob) AsOwner() meta.OwnerReference { trueVar := true return meta.OwnerReference{ APIVersion: SchemeGroupVersion.String(), Kind: ml.ArangoMLBatchJobResourceKind, - Name: d.Name, - UID: d.UID, + Name: a.Name, + UID: a.UID, Controller: &trueVar, } } @@ -67,3 +71,57 @@ func (a *ArangoMLBatchJob) GetStatus() ArangoMLBatchJobStatus { func (a *ArangoMLBatchJob) SetStatus(status ArangoMLBatchJobStatus) { a.Status = status } + +func (a *ArangoMLBatchJob) GetJobType() string { + val, ok := a.Labels[constants.MLJobTypeLabel] + if !ok { + return "" + } + return strings.ToLower(val) +} + +func (a *ArangoMLBatchJob) GetScheduleType() string { + val, ok := a.Labels[constants.MLJobScheduleLabel] + if !ok { + return "" + } + return strings.ToLower(val) +} + +func (a *ArangoMLBatchJob) GetMLDeploymentName() string { + val, ok := a.Labels[constants.MLJobScheduleLabel] + if !ok { + return "" + } + return val +} + +func (a *ArangoMLBatchJob) ValidateLabels() error { + depl, ok := a.Labels[constants.MLDeploymentLabel] + if !ok { + return errors.Newf("Job missing label: %s", constants.MLDeploymentLabel) + } + if depl == "" { + return errors.Newf("Job empty value for label: %s", constants.MLDeploymentLabel) + } + + t, ok := a.Labels[constants.MLJobTypeLabel] + if !ok { + return errors.Newf("Job missing label: %s", constants.MLJobTypeLabel) + } + jobType := strings.ToLower(t) + if jobType != constants.MLJobTrainingType && jobType != constants.MLJobPredictionType { + return errors.Newf("Job label (%s) has unexpected value: %s", constants.MLJobTypeLabel, t) + } + + s, ok := a.Labels[constants.MLJobScheduleLabel] + if !ok { + return errors.Newf("Job missing label: %s", constants.MLJobTypeLabel) + } + scheduleType := strings.ToLower(s) + if scheduleType != constants.MLJobScheduleCPU && scheduleType != constants.MLJobScheduleGPU { + return errors.Newf("Job label (%s) has unexpected value: %s", constants.MLJobScheduleLabel, s) + } + + return nil +} diff --git a/pkg/apis/ml/v1alpha1/batchjob_spec.go b/pkg/apis/ml/v1alpha1/batchjob_spec.go index cf0b5ab1a..a803798c4 100644 --- a/pkg/apis/ml/v1alpha1/batchjob_spec.go +++ b/pkg/apis/ml/v1alpha1/batchjob_spec.go @@ -43,5 +43,9 @@ func (a *ArangoMLBatchJobSpec) Validate() error { err = append(err, shared.PrefixResourceErrors("spec", errors.Newf("JobSpec is not defined"))) } + if len(a.JobSpec.Template.Spec.Containers) != 1 { + err = append(err, shared.PrefixResourceErrors("spec.template.spec.containers", errors.Newf("Exactly one container is required"))) + } + return shared.WithErrors(err...) } diff --git a/pkg/apis/ml/v1alpha1/cronjob_spec.go b/pkg/apis/ml/v1alpha1/cronjob_spec.go index 6a085ba63..602ea3662 100644 --- a/pkg/apis/ml/v1alpha1/cronjob_spec.go +++ b/pkg/apis/ml/v1alpha1/cronjob_spec.go @@ -43,5 +43,10 @@ func (a *ArangoMLCronJobSpec) Validate() error { err = append(err, shared.PrefixResourceErrors("spec", errors.Newf("CronJobSpec is not defined"))) } + if len(a.CronJobSpec.JobTemplate.Spec.Template.Spec.Containers) != 1 { + err = append(err, shared.PrefixResourceErrors("spec.jobTemplate.spec.template.spec.containers", + errors.Newf("Exactly one container is required"))) + } + 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 82a4af02c..99fd79ea0 100644 --- a/pkg/apis/ml/v1alpha1/extension_spec_job.go +++ b/pkg/apis/ml/v1alpha1/extension_spec_job.go @@ -27,37 +27,31 @@ import ( type ArangoMLJobsTemplates struct { // Prediction defines template for the prediction job - Prediction *ArangoMLExtensionTemplateSpec `json:"prediction,omitempty"` + Prediction map[string]*ArangoMLExtensionTemplateSpec `json:"prediction,omitempty"` // Training defines template for the training job - Training *ArangoMLExtensionTemplateSpec `json:"training,omitempty"` + Training map[string]*ArangoMLExtensionTemplateSpec `json:"training,omitempty"` } -func (j *ArangoMLJobsTemplates) GetPrediction() *ArangoMLExtensionTemplateSpec { +func (j *ArangoMLJobsTemplates) Validate() error { if j == nil { return nil } - return j.Prediction -} - -func (j *ArangoMLJobsTemplates) GetTraining() *ArangoMLExtensionTemplateSpec { - if j == nil { - return nil + var errs []error + for _, template := range j.Prediction { + if err := template.Validate(); err != nil { + errs = append(errs, shared.PrefixResourceErrors("prediction", err)) + } } - return j.Training -} - -func (j *ArangoMLJobsTemplates) Validate() error { - if j == nil { - return nil + for _, template := range j.Training { + if err := template.Validate(); err != nil { + errs = append(errs, shared.PrefixResourceErrors("training", err)) + } } - return shared.WithErrors( - j.GetPrediction().Validate(), - j.GetTraining().Validate(), - ) + return shared.WithErrors(errs...) } type ArangoMLExtensionTemplateSpec struct { diff --git a/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go index 52f0ba01f..1fadc913f 100644 --- a/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go @@ -642,13 +642,33 @@ func (in *ArangoMLJobsTemplates) DeepCopyInto(out *ArangoMLJobsTemplates) { *out = *in if in.Prediction != nil { in, out := &in.Prediction, &out.Prediction - *out = new(ArangoMLExtensionTemplateSpec) - (*in).DeepCopyInto(*out) + *out = make(map[string]*ArangoMLExtensionTemplateSpec, len(*in)) + for key, val := range *in { + var outVal *ArangoMLExtensionTemplateSpec + if val == nil { + (*out)[key] = nil + } else { + in, out := &val, &outVal + *out = new(ArangoMLExtensionTemplateSpec) + (*in).DeepCopyInto(*out) + } + (*out)[key] = outVal + } } if in.Training != nil { in, out := &in.Training, &out.Training - *out = new(ArangoMLExtensionTemplateSpec) - (*in).DeepCopyInto(*out) + *out = make(map[string]*ArangoMLExtensionTemplateSpec, len(*in)) + for key, val := range *in { + var outVal *ArangoMLExtensionTemplateSpec + if val == nil { + (*out)[key] = nil + } else { + in, out := &val, &outVal + *out = new(ArangoMLExtensionTemplateSpec) + (*in).DeepCopyInto(*out) + } + (*out)[key] = outVal + } } return } diff --git a/pkg/crd/crds/ml-extension.schema.generated.yaml b/pkg/crd/crds/ml-extension.schema.generated.yaml index 780085483..aecda4b17 100644 --- a/pkg/crd/crds/ml-extension.schema.generated.yaml +++ b/pkg/crd/crds/ml-extension.schema.generated.yaml @@ -1200,988 +1200,992 @@ v1alpha1: description: JobsTemplates defines templates for jobs properties: prediction: - description: Prediction defines template for the prediction job - properties: - affinity: - description: Affinity defines scheduling constraints for workload - properties: - nodeAffinity: - properties: - preferredDuringSchedulingIgnoredDuringExecution: - items: - properties: - preference: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: - type: string - values: - items: + additionalProperties: + properties: + affinity: + description: Affinity defines scheduling constraints for workload + properties: + nodeAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + preference: + properties: + matchExpressions: + items: + properties: + key: type: string - type: array - type: object - type: array - matchFields: - items: - properties: - key: - type: string - operator: - type: string - values: - items: + operator: type: string - type: array - type: object - type: array - type: object - weight: - format: int32 - type: integer - type: object - type: array - requiredDuringSchedulingIgnoredDuringExecution: - properties: - nodeSelectorTerms: - items: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: - type: string - values: - items: + values: + items: + type: string + type: array + type: object + type: array + matchFields: + items: + properties: + key: type: string - type: array - type: object - type: array - matchFields: - items: - properties: - key: - type: string - operator: - type: string - values: - items: + operator: type: string - type: array - type: object - type: array - type: object - type: array - type: object - type: object - podAffinity: - properties: - preferredDuringSchedulingIgnoredDuringExecution: - items: - properties: - podAffinityTerm: - properties: - labelSelector: - properties: - matchExpressions: - items: - properties: - key: + values: + items: type: string - operator: - type: string - values: - items: - type: string - type: array - type: object - type: array - matchLabels: - additionalProperties: - type: string + type: array type: object - type: object - namespaceSelector: - properties: - matchExpressions: - items: - properties: - key: + type: array + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + properties: + nodeSelectorTerms: + items: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: type: string - operator: + type: array + type: object + type: array + matchFields: + items: + properties: + key: + type: string + operator: + type: string + values: + items: type: string - values: - items: - type: string - type: array - type: object - type: array - matchLabels: - additionalProperties: - type: string + type: array type: object - type: object - namespaces: - items: - type: string - type: array - topologyKey: - type: string - type: object - weight: - format: int32 - type: integer + type: array + type: object + type: array type: object - type: array - requiredDuringSchedulingIgnoredDuringExecution: - items: - properties: - labelSelector: - properties: - matchExpressions: - items: + type: object + podAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + podAffinityTerm: + properties: + labelSelector: properties: - key: - type: string - operator: - type: string - values: + matchExpressions: items: - type: string + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object type: array + matchLabels: + additionalProperties: + type: string + type: object type: object - type: array - matchLabels: - additionalProperties: - type: string - type: object - type: object - namespaceSelector: - properties: - matchExpressions: - items: + namespaceSelector: properties: - key: - type: string - operator: - type: string - values: + matchExpressions: items: - type: string + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object type: array + matchLabels: + additionalProperties: + type: string + type: object type: object - type: array - matchLabels: - additionalProperties: + namespaces: + items: + type: string + type: array + topologyKey: type: string - type: object - type: object - namespaces: - items: - type: string - type: array - topologyKey: - type: string - type: object - type: array - type: object - podAntiAffinity: - properties: - preferredDuringSchedulingIgnoredDuringExecution: - items: - properties: - podAffinityTerm: - properties: - labelSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + items: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: type: string - values: - items: - type: string - type: array - type: object - type: array - matchLabels: - additionalProperties: - type: string + type: array type: object - type: object - namespaceSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: type: string - values: - items: - type: string - type: array - type: object - type: array - matchLabels: - additionalProperties: - type: string + type: array type: object - type: object - namespaces: - items: - type: string - type: array - topologyKey: + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: type: string - type: object - weight: - format: int32 - type: integer - type: object - type: array - requiredDuringSchedulingIgnoredDuringExecution: - items: - properties: - labelSelector: - properties: - matchExpressions: - items: + type: array + topologyKey: + type: string + type: object + type: array + type: object + podAntiAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + podAffinityTerm: + properties: + labelSelector: properties: - key: - type: string - operator: - type: string - values: + matchExpressions: items: - type: string + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object type: array + matchLabels: + additionalProperties: + type: string + type: object type: object - type: array - matchLabels: - additionalProperties: - type: string - type: object - type: object - namespaceSelector: - properties: - matchExpressions: - items: + namespaceSelector: properties: - key: - type: string - operator: - type: string - values: + matchExpressions: items: - type: string + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object type: array + matchLabels: + additionalProperties: + type: string + type: object type: object - type: array - matchLabels: - additionalProperties: + namespaces: + items: + type: string + type: array + topologyKey: type: string - type: object - type: object - namespaces: - items: + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + items: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: + type: string + type: array + topologyKey: type: string - type: array - topologyKey: - type: string - type: object - type: array - 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 - image: - description: Image define image details - type: string - nodeSelector: - additionalProperties: + type: object + type: array + 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 + image: + description: Image define image details 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 - type: integer - fsGroupChangePolicy: + nodeSelector: + additionalProperties: type: string - runAsGroup: - format: int64 - type: integer - runAsNonRoot: - type: boolean - runAsUser: - format: int64 - type: integer - seLinuxOptions: - properties: - level: - type: string - role: - type: string - type: - type: string - user: - type: string - type: object - seccompProfile: - properties: - localhostProfile: - type: string - type: - type: string - type: object - supplementalGroups: - items: + 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 type: integer - type: array - sysctls: - items: + fsGroupChangePolicy: + type: string + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: properties: - name: + level: + type: string + role: + type: string + type: type: string - value: + user: type: string type: object - type: array - windowsOptions: - properties: - gmsaCredentialSpec: - type: string - gmsaCredentialSpecName: + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + type: object + supplementalGroups: + items: + format: int64 + type: integer + type: array + sysctls: + items: + properties: + name: + type: string + value: + type: string + type: object + type: array + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + 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: + limits: + additionalProperties: type: string - hostProcess: - type: boolean - runAsUserName: + type: object + requests: + additionalProperties: 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: 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 - type: array - resources: - description: Resources holds resource requests & limits for container - properties: - limits: - additionalProperties: - type: string - type: object - requests: - additionalProperties: + securityContext: + description: PodSecurityContext holds pod-level security attributes and common container settings. + properties: + allowPrivilegeEscalation: + type: boolean + capabilities: + properties: + add: + items: + type: string + type: array + drop: + items: + type: string + type: array + type: object + privileged: + type: boolean + procMount: type: string - 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 - capabilities: - properties: - add: - items: + readOnlyRootFilesystem: + type: boolean + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: type: string - type: array - drop: - items: + role: type: string - type: array - type: object - privileged: - type: boolean - procMount: - type: string - readOnlyRootFilesystem: - type: boolean - runAsGroup: - format: int64 - type: integer - runAsNonRoot: - type: boolean - runAsUser: - format: int64 - type: integer - seLinuxOptions: + type: + type: string + user: + type: string + type: object + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + type: object + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + type: string + 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: - level: - type: string - role: - type: string - type: + effect: type: string - user: + key: type: string - type: object - seccompProfile: - properties: - localhostProfile: + operator: type: string - type: + tolerationSeconds: + format: int64 + type: integer + value: type: string type: object - windowsOptions: - properties: - gmsaCredentialSpec: - type: string - gmsaCredentialSpecName: - type: string - hostProcess: - type: boolean - runAsUserName: - type: string - 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: - type: string - key: - type: string - operator: - type: string - tolerationSeconds: - format: int64 - type: integer - value: - type: string - type: object - type: array + type: array + type: object + description: Prediction defines template for the prediction job type: object training: - description: Training defines template for the training job - properties: - affinity: - description: Affinity defines scheduling constraints for workload - properties: - nodeAffinity: - properties: - preferredDuringSchedulingIgnoredDuringExecution: - items: - properties: - preference: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: - type: string - values: - items: + additionalProperties: + properties: + affinity: + description: Affinity defines scheduling constraints for workload + properties: + nodeAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + preference: + properties: + matchExpressions: + items: + properties: + key: type: string - type: array - type: object - type: array - matchFields: - items: - properties: - key: - type: string - operator: - type: string - values: - items: + operator: type: string - type: array - type: object - type: array - type: object - weight: - format: int32 - type: integer - type: object - type: array - requiredDuringSchedulingIgnoredDuringExecution: - properties: - nodeSelectorTerms: - items: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: - type: string - values: - items: + values: + items: + type: string + type: array + type: object + type: array + matchFields: + items: + properties: + key: type: string - type: array - type: object - type: array - matchFields: - items: - properties: - key: - type: string - operator: - type: string - values: - items: + operator: type: string - type: array - type: object - type: array - type: object - type: array - type: object - type: object - podAffinity: - properties: - preferredDuringSchedulingIgnoredDuringExecution: - items: - properties: - podAffinityTerm: - properties: - labelSelector: - properties: - matchExpressions: - items: - properties: - key: + values: + items: type: string - operator: - type: string - values: - items: - type: string - type: array - type: object - type: array - matchLabels: - additionalProperties: - type: string + type: array type: object - type: object - namespaceSelector: - properties: - matchExpressions: - items: - properties: - key: + type: array + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + properties: + nodeSelectorTerms: + items: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: type: string - operator: + type: array + type: object + type: array + matchFields: + items: + properties: + key: + type: string + operator: + type: string + values: + items: type: string - values: - items: - type: string - type: array - type: object - type: array - matchLabels: - additionalProperties: - type: string + type: array type: object - type: object - namespaces: - items: - type: string - type: array - topologyKey: - type: string - type: object - weight: - format: int32 - type: integer + type: array + type: object + type: array type: object - type: array - requiredDuringSchedulingIgnoredDuringExecution: - items: - properties: - labelSelector: - properties: - matchExpressions: - items: + type: object + podAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + podAffinityTerm: + properties: + labelSelector: properties: - key: - type: string - operator: - type: string - values: + matchExpressions: items: - type: string + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object type: array + matchLabels: + additionalProperties: + type: string + type: object type: object - type: array - matchLabels: - additionalProperties: - type: string - type: object - type: object - namespaceSelector: - properties: - matchExpressions: - items: + namespaceSelector: properties: - key: - type: string - operator: - type: string - values: + matchExpressions: items: - type: string + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object type: array + matchLabels: + additionalProperties: + type: string + type: object type: object - type: array - matchLabels: - additionalProperties: + namespaces: + items: + type: string + type: array + topologyKey: type: string - type: object - type: object - namespaces: - items: - type: string - type: array - topologyKey: - type: string - type: object - type: array - type: object - podAntiAffinity: - properties: - preferredDuringSchedulingIgnoredDuringExecution: - items: - properties: - podAffinityTerm: - properties: - labelSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + items: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: type: string - values: - items: - type: string - type: array - type: object - type: array - matchLabels: - additionalProperties: - type: string + type: array type: object - type: object - namespaceSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: type: string - values: - items: - type: string - type: array - type: object - type: array - matchLabels: - additionalProperties: - type: string + type: array type: object - type: object - namespaces: - items: - type: string - type: array - topologyKey: - type: string - type: object - weight: - format: int32 - type: integer - type: object - type: array - requiredDuringSchedulingIgnoredDuringExecution: - items: - properties: - labelSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: - type: string - values: - items: - type: string - type: array + type: array + matchLabels: + additionalProperties: + type: string type: object - type: array - matchLabels: - additionalProperties: - type: string - type: object - type: object - namespaceSelector: - properties: - matchExpressions: - items: + type: object + namespaces: + items: + type: string + type: array + topologyKey: + type: string + type: object + type: array + type: object + podAntiAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + podAffinityTerm: + properties: + labelSelector: properties: - key: - type: string - operator: - type: string - values: + matchExpressions: items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object type: array + matchLabels: + additionalProperties: + type: string + type: object type: object - type: array - matchLabels: - additionalProperties: + namespaces: + items: + type: string + type: array + topologyKey: type: string - type: object - type: object - namespaces: - items: + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + items: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: + type: string + type: array + topologyKey: type: string - type: array - topologyKey: - type: string - type: object - type: array - 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 - image: - description: Image define image details - type: string - nodeSelector: - additionalProperties: + type: object + type: array + 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 + image: + description: Image define image details 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 - type: integer - fsGroupChangePolicy: + nodeSelector: + additionalProperties: type: string - runAsGroup: - format: int64 - type: integer - runAsNonRoot: - type: boolean - runAsUser: - format: int64 - type: integer - seLinuxOptions: - properties: - level: - type: string - role: - type: string - type: - type: string - user: - type: string - type: object - seccompProfile: - properties: - localhostProfile: - type: string - type: - type: string - type: object - supplementalGroups: - items: + 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 type: integer - type: array - sysctls: - items: + fsGroupChangePolicy: + type: string + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: + type: string + role: + type: string + type: + type: string + user: + type: string + type: object + seccompProfile: properties: - name: + localhostProfile: type: string - value: + type: type: string type: object - type: array - windowsOptions: - properties: - gmsaCredentialSpec: - type: string - gmsaCredentialSpecName: + supplementalGroups: + items: + format: int64 + type: integer + type: array + sysctls: + items: + properties: + name: + type: string + value: + type: string + type: object + type: array + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + 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: + limits: + additionalProperties: type: string - hostProcess: - type: boolean - runAsUserName: + type: object + requests: + additionalProperties: 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: 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 - type: array - resources: - description: Resources holds resource requests & limits for container - properties: - limits: - additionalProperties: - type: string - type: object - requests: - additionalProperties: + securityContext: + description: PodSecurityContext holds pod-level security attributes and common container settings. + properties: + allowPrivilegeEscalation: + type: boolean + capabilities: + properties: + add: + items: + type: string + type: array + drop: + items: + type: string + type: array + type: object + privileged: + type: boolean + procMount: type: string - 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 - capabilities: - properties: - add: - items: + readOnlyRootFilesystem: + type: boolean + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: type: string - type: array - drop: - items: + role: type: string - type: array - type: object - privileged: - type: boolean - procMount: - type: string - readOnlyRootFilesystem: - type: boolean - runAsGroup: - format: int64 - type: integer - runAsNonRoot: - type: boolean - runAsUser: - format: int64 - type: integer - seLinuxOptions: - properties: - level: - type: string - role: - type: string - type: - type: string - user: - type: string - type: object - seccompProfile: + type: + type: string + user: + type: string + type: object + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + type: object + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + type: string + 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: - localhostProfile: - type: string - type: + effect: type: string - type: object - windowsOptions: - properties: - gmsaCredentialSpec: + key: type: string - gmsaCredentialSpecName: + operator: type: string - hostProcess: - type: boolean - runAsUserName: + tolerationSeconds: + format: int64 + type: integer + value: type: string 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: - type: string - key: - type: string - operator: - type: string - tolerationSeconds: - format: int64 - type: integer - value: - type: string - type: object - type: array + type: array + type: object + description: Training defines template for the training job type: object type: object metadataService: diff --git a/pkg/util/constants/constants.go b/pkg/util/constants/constants.go index b0b45f70c..38e668760 100644 --- a/pkg/util/constants/constants.go +++ b/pkg/util/constants/constants.go @@ -71,6 +71,16 @@ const ( ClusterSyncLabelRole = "clustersync/role" LabelRole = "role" LabelRoleLeader = "leader" + + MLDeploymentLabel = "cloud.arangodb.com/deployment" + MLJobTypeLabel = "job.cloud.arangodb.com/type" + MLJobScheduleLabel = "job.cloud.arangodb.com/schedule" + + MLJobTrainingType = "training" + MLJobPredictionType = "prediction" + + MLJobScheduleCPU = "cpu" + MLJobScheduleGPU = "gpu" ) func ManagedFinalizers() []string { From f64afeea3f78e089ecb31cac5f413a7490fc90ad Mon Sep 17 00:00:00 2001 From: jwierzbo Date: Fri, 15 Dec 2023 10:49:01 +0100 Subject: [PATCH 3/7] Validation changes --- pkg/apis/ml/v1alpha1/batchjob.go | 30 +++++++++++----------- pkg/apis/ml/v1alpha1/extension_spec_job.go | 8 ++---- pkg/util/constants/constants.go | 10 -------- 3 files changed, 17 insertions(+), 31 deletions(-) diff --git a/pkg/apis/ml/v1alpha1/batchjob.go b/pkg/apis/ml/v1alpha1/batchjob.go index 78aaa9ef5..721937d8d 100644 --- a/pkg/apis/ml/v1alpha1/batchjob.go +++ b/pkg/apis/ml/v1alpha1/batchjob.go @@ -26,7 +26,7 @@ import ( meta "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/arangodb/kube-arangodb/pkg/apis/ml" - "github.com/arangodb/kube-arangodb/pkg/util/constants" + mlShared "github.com/arangodb/kube-arangodb/pkg/handlers/enterprise/ml/shared" "github.com/arangodb/kube-arangodb/pkg/util/errors" ) @@ -73,7 +73,7 @@ func (a *ArangoMLBatchJob) SetStatus(status ArangoMLBatchJobStatus) { } func (a *ArangoMLBatchJob) GetJobType() string { - val, ok := a.Labels[constants.MLJobTypeLabel] + val, ok := a.Labels[mlShared.MLJobTypeLabel] if !ok { return "" } @@ -81,7 +81,7 @@ func (a *ArangoMLBatchJob) GetJobType() string { } func (a *ArangoMLBatchJob) GetScheduleType() string { - val, ok := a.Labels[constants.MLJobScheduleLabel] + val, ok := a.Labels[mlShared.MLJobScheduleLabel] if !ok { return "" } @@ -89,7 +89,7 @@ func (a *ArangoMLBatchJob) GetScheduleType() string { } func (a *ArangoMLBatchJob) GetMLDeploymentName() string { - val, ok := a.Labels[constants.MLJobScheduleLabel] + val, ok := a.Labels[mlShared.MLJobScheduleLabel] if !ok { return "" } @@ -97,30 +97,30 @@ func (a *ArangoMLBatchJob) GetMLDeploymentName() string { } func (a *ArangoMLBatchJob) ValidateLabels() error { - depl, ok := a.Labels[constants.MLDeploymentLabel] + depl, ok := a.Labels[mlShared.MLDeploymentLabel] if !ok { - return errors.Newf("Job missing label: %s", constants.MLDeploymentLabel) + return errors.Newf("Job missing label: %s", mlShared.MLDeploymentLabel) } if depl == "" { - return errors.Newf("Job empty value for label: %s", constants.MLDeploymentLabel) + return errors.Newf("Job empty value for label: %s", mlShared.MLDeploymentLabel) } - t, ok := a.Labels[constants.MLJobTypeLabel] + t, ok := a.Labels[mlShared.MLJobTypeLabel] if !ok { - return errors.Newf("Job missing label: %s", constants.MLJobTypeLabel) + return errors.Newf("Job missing label: %s", mlShared.MLJobTypeLabel) } jobType := strings.ToLower(t) - if jobType != constants.MLJobTrainingType && jobType != constants.MLJobPredictionType { - return errors.Newf("Job label (%s) has unexpected value: %s", constants.MLJobTypeLabel, t) + if jobType != mlShared.MLJobTrainingType && jobType != mlShared.MLJobPredictionType { + return errors.Newf("Job label (%s) has unexpected value: %s", mlShared.MLJobTypeLabel, t) } - s, ok := a.Labels[constants.MLJobScheduleLabel] + s, ok := a.Labels[mlShared.MLJobScheduleLabel] if !ok { - return errors.Newf("Job missing label: %s", constants.MLJobTypeLabel) + return errors.Newf("Job missing label: %s", mlShared.MLJobTypeLabel) } scheduleType := strings.ToLower(s) - if scheduleType != constants.MLJobScheduleCPU && scheduleType != constants.MLJobScheduleGPU { - return errors.Newf("Job label (%s) has unexpected value: %s", constants.MLJobScheduleLabel, s) + if scheduleType != mlShared.MLJobScheduleCPU && scheduleType != mlShared.MLJobScheduleGPU { + return errors.Newf("Job label (%s) has unexpected value: %s", mlShared.MLJobScheduleLabel, s) } return nil diff --git a/pkg/apis/ml/v1alpha1/extension_spec_job.go b/pkg/apis/ml/v1alpha1/extension_spec_job.go index 99fd79ea0..0582d2ef4 100644 --- a/pkg/apis/ml/v1alpha1/extension_spec_job.go +++ b/pkg/apis/ml/v1alpha1/extension_spec_job.go @@ -40,15 +40,11 @@ func (j *ArangoMLJobsTemplates) Validate() error { var errs []error for _, template := range j.Prediction { - if err := template.Validate(); err != nil { - errs = append(errs, shared.PrefixResourceErrors("prediction", err)) - } + errs = append(errs, shared.PrefixResourceErrors("prediction", template.Validate())) } for _, template := range j.Training { - if err := template.Validate(); err != nil { - errs = append(errs, shared.PrefixResourceErrors("training", err)) - } + errs = append(errs, shared.PrefixResourceErrors("training", template.Validate())) } return shared.WithErrors(errs...) diff --git a/pkg/util/constants/constants.go b/pkg/util/constants/constants.go index 38e668760..b0b45f70c 100644 --- a/pkg/util/constants/constants.go +++ b/pkg/util/constants/constants.go @@ -71,16 +71,6 @@ const ( ClusterSyncLabelRole = "clustersync/role" LabelRole = "role" LabelRoleLeader = "leader" - - MLDeploymentLabel = "cloud.arangodb.com/deployment" - MLJobTypeLabel = "job.cloud.arangodb.com/type" - MLJobScheduleLabel = "job.cloud.arangodb.com/schedule" - - MLJobTrainingType = "training" - MLJobPredictionType = "prediction" - - MLJobScheduleCPU = "cpu" - MLJobScheduleGPU = "gpu" ) func ManagedFinalizers() []string { From fac86f9d8ed9e418e02f419ea37338dbbe4df327 Mon Sep 17 00:00:00 2001 From: jwierzbo Date: Fri, 15 Dec 2023 20:10:15 +0100 Subject: [PATCH 4/7] CPU and GPU schedule type jobs --- docs/api/ArangoMLExtension.V1Alpha1.md | 350 ++- pkg/apis/ml/v1alpha1/batchjob.go | 58 - pkg/apis/ml/v1alpha1/batchjob_spec.go | 2 +- pkg/apis/ml/v1alpha1/cronjob_spec.go | 2 +- pkg/apis/ml/v1alpha1/extension_conditions.go | 1 + pkg/apis/ml/v1alpha1/extension_spec_job.go | 69 +- pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go | 54 +- .../crds/ml-extension.schema.generated.yaml | 2718 +++++++++++------ pkg/util/labels.go | 30 + 9 files changed, 2297 insertions(+), 987 deletions(-) create mode 100644 pkg/util/labels.go diff --git a/docs/api/ArangoMLExtension.V1Alpha1.md b/docs/api/ArangoMLExtension.V1Alpha1.md index cc6483734..0aeb7af04 100644 --- a/docs/api/ArangoMLExtension.V1Alpha1.md +++ b/docs/api/ArangoMLExtension.V1Alpha1.md @@ -451,7 +451,7 @@ Links: *** -### .spec.jobsTemplates.prediction.\.affinity +### .spec.jobsTemplates.prediction.cpu.affinity Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L37) @@ -462,7 +462,7 @@ Links: *** -### .spec.jobsTemplates.prediction.\.hostIPC +### .spec.jobsTemplates.prediction.cpu.hostIPC Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L33) @@ -472,7 +472,7 @@ Default Value: `false` *** -### .spec.jobsTemplates.prediction.\.hostNetwork +### .spec.jobsTemplates.prediction.cpu.hostNetwork Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L27) @@ -483,7 +483,7 @@ Default Value: `false` *** -### .spec.jobsTemplates.prediction.\.hostPID +### .spec.jobsTemplates.prediction.cpu.hostPID Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L30) @@ -493,7 +493,7 @@ Default Value: `false` *** -### .spec.jobsTemplates.prediction.\.image +### .spec.jobsTemplates.prediction.cpu.image Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L31) @@ -501,7 +501,7 @@ Image define image details *** -### .spec.jobsTemplates.prediction.\.nodeSelector +### .spec.jobsTemplates.prediction.cpu.nodeSelector Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L32) @@ -512,7 +512,7 @@ Links: *** -### .spec.jobsTemplates.prediction.\.podSecurityContext +### .spec.jobsTemplates.prediction.cpu.podSecurityContext Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_pod.go#L29) @@ -523,7 +523,7 @@ Links: *** -### .spec.jobsTemplates.prediction.\.pullPolicy +### .spec.jobsTemplates.prediction.cpu.pullPolicy Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L35) @@ -533,7 +533,7 @@ Default Value: `IfNotPresent` *** -### .spec.jobsTemplates.prediction.\.pullSecrets +### .spec.jobsTemplates.prediction.cpu.pullSecrets Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L38) @@ -541,7 +541,7 @@ PullSecrets define Secrets used to pull Image from registry *** -### .spec.jobsTemplates.prediction.\.resources +### .spec.jobsTemplates.prediction.cpu.resources Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/resources.go#L34) @@ -552,7 +552,7 @@ Links: *** -### .spec.jobsTemplates.prediction.\.schedulerName +### .spec.jobsTemplates.prediction.cpu.schedulerName Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L47) @@ -563,7 +563,7 @@ Default Value: `""` *** -### .spec.jobsTemplates.prediction.\.securityContext +### .spec.jobsTemplates.prediction.cpu.securityContext Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_container.go#L29) @@ -574,7 +574,7 @@ Links: *** -### .spec.jobsTemplates.prediction.\.shareProcessNamespace +### .spec.jobsTemplates.prediction.cpu.shareProcessNamespace Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L39) @@ -587,7 +587,7 @@ Default Value: `false` *** -### .spec.jobsTemplates.prediction.\.tolerations +### .spec.jobsTemplates.prediction.cpu.tolerations Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L42) @@ -598,7 +598,7 @@ Links: *** -### .spec.jobsTemplates.training.\.affinity +### .spec.jobsTemplates.prediction.gpu.affinity Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L37) @@ -609,7 +609,7 @@ Links: *** -### .spec.jobsTemplates.training.\.hostIPC +### .spec.jobsTemplates.prediction.gpu.hostIPC Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L33) @@ -619,7 +619,7 @@ Default Value: `false` *** -### .spec.jobsTemplates.training.\.hostNetwork +### .spec.jobsTemplates.prediction.gpu.hostNetwork Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L27) @@ -630,7 +630,7 @@ Default Value: `false` *** -### .spec.jobsTemplates.training.\.hostPID +### .spec.jobsTemplates.prediction.gpu.hostPID Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L30) @@ -640,7 +640,7 @@ Default Value: `false` *** -### .spec.jobsTemplates.training.\.image +### .spec.jobsTemplates.prediction.gpu.image Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L31) @@ -648,7 +648,7 @@ Image define image details *** -### .spec.jobsTemplates.training.\.nodeSelector +### .spec.jobsTemplates.prediction.gpu.nodeSelector Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L32) @@ -659,7 +659,7 @@ Links: *** -### .spec.jobsTemplates.training.\.podSecurityContext +### .spec.jobsTemplates.prediction.gpu.podSecurityContext Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_pod.go#L29) @@ -670,7 +670,7 @@ Links: *** -### .spec.jobsTemplates.training.\.pullPolicy +### .spec.jobsTemplates.prediction.gpu.pullPolicy Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L35) @@ -680,7 +680,7 @@ Default Value: `IfNotPresent` *** -### .spec.jobsTemplates.training.\.pullSecrets +### .spec.jobsTemplates.prediction.gpu.pullSecrets Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L38) @@ -688,7 +688,7 @@ PullSecrets define Secrets used to pull Image from registry *** -### .spec.jobsTemplates.training.\.resources +### .spec.jobsTemplates.prediction.gpu.resources Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/resources.go#L34) @@ -699,7 +699,7 @@ Links: *** -### .spec.jobsTemplates.training.\.schedulerName +### .spec.jobsTemplates.prediction.gpu.schedulerName Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L47) @@ -710,7 +710,7 @@ Default Value: `""` *** -### .spec.jobsTemplates.training.\.securityContext +### .spec.jobsTemplates.prediction.gpu.securityContext Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_container.go#L29) @@ -721,7 +721,7 @@ Links: *** -### .spec.jobsTemplates.training.\.shareProcessNamespace +### .spec.jobsTemplates.prediction.gpu.shareProcessNamespace Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L39) @@ -734,7 +734,301 @@ Default Value: `false` *** -### .spec.jobsTemplates.training.\.tolerations +### .spec.jobsTemplates.prediction.gpu.tolerations + +Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L42) + +Tolerations defines tolerations + +Links: +* [Kubernetes docs](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) + +*** + +### .spec.jobsTemplates.training.cpu.affinity + +Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L37) + +Affinity defines scheduling constraints for workload + +Links: +* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity) + +*** + +### .spec.jobsTemplates.training.cpu.hostIPC + +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L33) + +HostIPC defines to use the host's ipc namespace. + +Default Value: `false` + +*** + +### .spec.jobsTemplates.training.cpu.hostNetwork + +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L27) + +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. + +Default Value: `false` + +*** + +### .spec.jobsTemplates.training.cpu.hostPID + +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L30) + +HostPID define to use the host's pid namespace. + +Default Value: `false` + +*** + +### .spec.jobsTemplates.training.cpu.image + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L31) + +Image define image details + +*** + +### .spec.jobsTemplates.training.cpu.nodeSelector + +Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L32) + +NodeSelector is a selector that must be true for the workload to fit on a node. + +Links: +* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) + +*** + +### .spec.jobsTemplates.training.cpu.podSecurityContext + +Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_pod.go#L29) + +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.training.cpu.pullPolicy + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L35) + +PullPolicy define Image pull policy + +Default Value: `IfNotPresent` + +*** + +### .spec.jobsTemplates.training.cpu.pullSecrets + +Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L38) + +PullSecrets define Secrets used to pull Image from registry + +*** + +### .spec.jobsTemplates.training.cpu.resources + +Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/resources.go#L34) + +Resources holds resource requests & limits for container + +Links: +* [Documentation of core.ResourceRequirements](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/#resourcerequirements-v1-core) + +*** + +### .spec.jobsTemplates.training.cpu.schedulerName + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L47) + +SchedulerName specifies, the pod will be dispatched by specified scheduler. +If not specified, the pod will be dispatched by default scheduler. + +Default Value: `""` + +*** + +### .spec.jobsTemplates.training.cpu.securityContext + +Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_container.go#L29) + +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.training.cpu.shareProcessNamespace + +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L39) + +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. + +Default Value: `false` + +*** + +### .spec.jobsTemplates.training.cpu.tolerations + +Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L42) + +Tolerations defines tolerations + +Links: +* [Kubernetes docs](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) + +*** + +### .spec.jobsTemplates.training.gpu.affinity + +Type: `core.Affinity` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L37) + +Affinity defines scheduling constraints for workload + +Links: +* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity) + +*** + +### .spec.jobsTemplates.training.gpu.hostIPC + +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L33) + +HostIPC defines to use the host's ipc namespace. + +Default Value: `false` + +*** + +### .spec.jobsTemplates.training.gpu.hostNetwork + +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L27) + +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. + +Default Value: `false` + +*** + +### .spec.jobsTemplates.training.gpu.hostPID + +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L30) + +HostPID define to use the host's pid namespace. + +Default Value: `false` + +*** + +### .spec.jobsTemplates.training.gpu.image + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L31) + +Image define image details + +*** + +### .spec.jobsTemplates.training.gpu.nodeSelector + +Type: `object` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L32) + +NodeSelector is a selector that must be true for the workload to fit on a node. + +Links: +* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) + +*** + +### .spec.jobsTemplates.training.gpu.podSecurityContext + +Type: `core.PodSecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_pod.go#L29) + +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.training.gpu.pullPolicy + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L35) + +PullPolicy define Image pull policy + +Default Value: `IfNotPresent` + +*** + +### .spec.jobsTemplates.training.gpu.pullSecrets + +Type: `array` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L38) + +PullSecrets define Secrets used to pull Image from registry + +*** + +### .spec.jobsTemplates.training.gpu.resources + +Type: `core.ResourceRequirements` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/resources.go#L34) + +Resources holds resource requests & limits for container + +Links: +* [Documentation of core.ResourceRequirements](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/#resourcerequirements-v1-core) + +*** + +### .spec.jobsTemplates.training.gpu.schedulerName + +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L47) + +SchedulerName specifies, the pod will be dispatched by specified scheduler. +If not specified, the pod will be dispatched by default scheduler. + +Default Value: `""` + +*** + +### .spec.jobsTemplates.training.gpu.securityContext + +Type: `core.SecurityContext` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_container.go#L29) + +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.training.gpu.shareProcessNamespace + +Type: `boolean` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L39) + +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. + +Default Value: `false` + +*** + +### .spec.jobsTemplates.training.gpu.tolerations Type: `[]core.Toleration` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L42) diff --git a/pkg/apis/ml/v1alpha1/batchjob.go b/pkg/apis/ml/v1alpha1/batchjob.go index 721937d8d..91d529cdc 100644 --- a/pkg/apis/ml/v1alpha1/batchjob.go +++ b/pkg/apis/ml/v1alpha1/batchjob.go @@ -21,13 +21,9 @@ package v1alpha1 import ( - "strings" - meta "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/arangodb/kube-arangodb/pkg/apis/ml" - mlShared "github.com/arangodb/kube-arangodb/pkg/handlers/enterprise/ml/shared" - "github.com/arangodb/kube-arangodb/pkg/util/errors" ) // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -71,57 +67,3 @@ func (a *ArangoMLBatchJob) GetStatus() ArangoMLBatchJobStatus { func (a *ArangoMLBatchJob) SetStatus(status ArangoMLBatchJobStatus) { a.Status = status } - -func (a *ArangoMLBatchJob) GetJobType() string { - val, ok := a.Labels[mlShared.MLJobTypeLabel] - if !ok { - return "" - } - return strings.ToLower(val) -} - -func (a *ArangoMLBatchJob) GetScheduleType() string { - val, ok := a.Labels[mlShared.MLJobScheduleLabel] - if !ok { - return "" - } - return strings.ToLower(val) -} - -func (a *ArangoMLBatchJob) GetMLDeploymentName() string { - val, ok := a.Labels[mlShared.MLJobScheduleLabel] - if !ok { - return "" - } - return val -} - -func (a *ArangoMLBatchJob) ValidateLabels() error { - depl, ok := a.Labels[mlShared.MLDeploymentLabel] - if !ok { - return errors.Newf("Job missing label: %s", mlShared.MLDeploymentLabel) - } - if depl == "" { - return errors.Newf("Job empty value for label: %s", mlShared.MLDeploymentLabel) - } - - t, ok := a.Labels[mlShared.MLJobTypeLabel] - if !ok { - return errors.Newf("Job missing label: %s", mlShared.MLJobTypeLabel) - } - jobType := strings.ToLower(t) - if jobType != mlShared.MLJobTrainingType && jobType != mlShared.MLJobPredictionType { - return errors.Newf("Job label (%s) has unexpected value: %s", mlShared.MLJobTypeLabel, t) - } - - s, ok := a.Labels[mlShared.MLJobScheduleLabel] - if !ok { - return errors.Newf("Job missing label: %s", mlShared.MLJobTypeLabel) - } - scheduleType := strings.ToLower(s) - if scheduleType != mlShared.MLJobScheduleCPU && scheduleType != mlShared.MLJobScheduleGPU { - return errors.Newf("Job label (%s) has unexpected value: %s", mlShared.MLJobScheduleLabel, s) - } - - return nil -} diff --git a/pkg/apis/ml/v1alpha1/batchjob_spec.go b/pkg/apis/ml/v1alpha1/batchjob_spec.go index a803798c4..5e7638265 100644 --- a/pkg/apis/ml/v1alpha1/batchjob_spec.go +++ b/pkg/apis/ml/v1alpha1/batchjob_spec.go @@ -40,7 +40,7 @@ func (a *ArangoMLBatchJobSpec) Validate() error { var err []error if a.JobSpec == nil { - err = append(err, shared.PrefixResourceErrors("spec", errors.Newf("JobSpec is not defined"))) + return shared.PrefixResourceErrors("spec", errors.Newf("JobSpec is not defined")) } if len(a.JobSpec.Template.Spec.Containers) != 1 { diff --git a/pkg/apis/ml/v1alpha1/cronjob_spec.go b/pkg/apis/ml/v1alpha1/cronjob_spec.go index 602ea3662..7c41a7220 100644 --- a/pkg/apis/ml/v1alpha1/cronjob_spec.go +++ b/pkg/apis/ml/v1alpha1/cronjob_spec.go @@ -40,7 +40,7 @@ func (a *ArangoMLCronJobSpec) Validate() error { var err []error if a.CronJobSpec == nil { - err = append(err, shared.PrefixResourceErrors("spec", errors.Newf("CronJobSpec is not defined"))) + return shared.PrefixResourceErrors("spec", errors.Newf("CronJobSpec is not defined")) } if len(a.CronJobSpec.JobTemplate.Spec.Template.Spec.Containers) != 1 { diff --git a/pkg/apis/ml/v1alpha1/extension_conditions.go b/pkg/apis/ml/v1alpha1/extension_conditions.go index 59b34cea8..cc45e9260 100644 --- a/pkg/apis/ml/v1alpha1/extension_conditions.go +++ b/pkg/apis/ml/v1alpha1/extension_conditions.go @@ -23,6 +23,7 @@ package v1alpha1 import api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" const ( + MLExtensionFoundCondition api.ConditionType = "MLExtensionFound" ExtensionStorageFoundCondition api.ConditionType = "StorageFound" ExtensionDeploymentFoundCondition api.ConditionType = "DeploymentFound" ExtensionBootstrapCompletedCondition api.ConditionType = "BootstrapCompleted" diff --git a/pkg/apis/ml/v1alpha1/extension_spec_job.go b/pkg/apis/ml/v1alpha1/extension_spec_job.go index 0582d2ef4..1a33fa76d 100644 --- a/pkg/apis/ml/v1alpha1/extension_spec_job.go +++ b/pkg/apis/ml/v1alpha1/extension_spec_job.go @@ -25,29 +25,78 @@ import ( sharedApi "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1" ) +type JobType string + +const ( + MLJobTrainingType JobType = "training" + MLJobPredictionType JobType = "prediction" +) + type ArangoMLJobsTemplates struct { // Prediction defines template for the prediction job - Prediction map[string]*ArangoMLExtensionTemplateSpec `json:"prediction,omitempty"` + Prediction *ArangoMLJobTemplates `json:"prediction,omitempty"` // Training defines template for the training job - Training map[string]*ArangoMLExtensionTemplateSpec `json:"training,omitempty"` + Training *ArangoMLJobTemplates `json:"training,omitempty"` +} + +func (a *ArangoMLJobsTemplates) GetJobTemplates(jobType JobType) *ArangoMLJobTemplates { + switch jobType { + case MLJobTrainingType: + return a.Prediction + case MLJobPredictionType: + return a.Training + default: + return nil + } } -func (j *ArangoMLJobsTemplates) Validate() error { - if j == nil { +func (a *ArangoMLJobsTemplates) Validate() error { + if a == nil { return nil } - var errs []error - for _, template := range j.Prediction { - errs = append(errs, shared.PrefixResourceErrors("prediction", template.Validate())) + return shared.WithErrors( + shared.PrefixResourceErrors("prediction", a.Prediction.Validate()), + shared.PrefixResourceErrors("training", a.Training.Validate()), + ) +} + +type JobScheduleType string + +const ( + MLJobScheduleCPU JobScheduleType = "cpu" + MLJobScheduleGPU JobScheduleType = "gpu" +) + +type ArangoMLJobTemplates struct { + // CPU defines templates for CPU jobs + CPU *ArangoMLExtensionTemplateSpec `json:"cpu,omitempty"` + + // GPU defines templates for GPU jobs + GPU *ArangoMLExtensionTemplateSpec `json:"gpu,omitempty"` +} + +func (a *ArangoMLJobTemplates) GetJobTemplateSpec(scheduleType JobScheduleType) *ArangoMLExtensionTemplateSpec { + switch scheduleType { + case MLJobScheduleCPU: + return a.CPU + case MLJobScheduleGPU: + return a.GPU + default: + return nil } +} - for _, template := range j.Training { - errs = append(errs, shared.PrefixResourceErrors("training", template.Validate())) +func (a *ArangoMLJobTemplates) Validate() error { + if a == nil { + return nil } - return shared.WithErrors(errs...) + return shared.WithErrors( + shared.PrefixResourceErrors("cpu", a.CPU.Validate()), + shared.PrefixResourceErrors("gpu", a.GPU.Validate()), + ) } type ArangoMLExtensionTemplateSpec struct { diff --git a/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go index 1fadc913f..e4b67b261 100644 --- a/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go @@ -637,38 +637,44 @@ func (in *ArangoMLExtensionTemplateSpec) DeepCopy() *ArangoMLExtensionTemplateSp return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoMLJobTemplates) DeepCopyInto(out *ArangoMLJobTemplates) { + *out = *in + if in.CPU != nil { + in, out := &in.CPU, &out.CPU + *out = new(ArangoMLExtensionTemplateSpec) + (*in).DeepCopyInto(*out) + } + if in.GPU != nil { + in, out := &in.GPU, &out.GPU + *out = new(ArangoMLExtensionTemplateSpec) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoMLJobTemplates. +func (in *ArangoMLJobTemplates) DeepCopy() *ArangoMLJobTemplates { + if in == nil { + return nil + } + out := new(ArangoMLJobTemplates) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ArangoMLJobsTemplates) DeepCopyInto(out *ArangoMLJobsTemplates) { *out = *in if in.Prediction != nil { in, out := &in.Prediction, &out.Prediction - *out = make(map[string]*ArangoMLExtensionTemplateSpec, len(*in)) - for key, val := range *in { - var outVal *ArangoMLExtensionTemplateSpec - if val == nil { - (*out)[key] = nil - } else { - in, out := &val, &outVal - *out = new(ArangoMLExtensionTemplateSpec) - (*in).DeepCopyInto(*out) - } - (*out)[key] = outVal - } + *out = new(ArangoMLJobTemplates) + (*in).DeepCopyInto(*out) } if in.Training != nil { in, out := &in.Training, &out.Training - *out = make(map[string]*ArangoMLExtensionTemplateSpec, len(*in)) - for key, val := range *in { - var outVal *ArangoMLExtensionTemplateSpec - if val == nil { - (*out)[key] = nil - } else { - in, out := &val, &outVal - *out = new(ArangoMLExtensionTemplateSpec) - (*in).DeepCopyInto(*out) - } - (*out)[key] = outVal - } + *out = new(ArangoMLJobTemplates) + (*in).DeepCopyInto(*out) } return } diff --git a/pkg/crd/crds/ml-extension.schema.generated.yaml b/pkg/crd/crds/ml-extension.schema.generated.yaml index aecda4b17..ee3f96063 100644 --- a/pkg/crd/crds/ml-extension.schema.generated.yaml +++ b/pkg/crd/crds/ml-extension.schema.generated.yaml @@ -1200,992 +1200,1980 @@ v1alpha1: description: JobsTemplates defines templates for jobs properties: prediction: - additionalProperties: - properties: - affinity: - description: Affinity defines scheduling constraints for workload - properties: - nodeAffinity: - properties: - preferredDuringSchedulingIgnoredDuringExecution: - items: - properties: - preference: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: - type: string - values: - items: + description: Prediction defines template for the prediction job + properties: + cpu: + description: CPU defines templates for CPU jobs + properties: + affinity: + description: Affinity defines scheduling constraints for workload + properties: + nodeAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + preference: + properties: + matchExpressions: + items: + properties: + key: type: string - type: array - type: object - type: array - matchFields: - items: - properties: - key: - type: string - operator: - type: string - values: - items: + operator: type: string - type: array - type: object - type: array - type: object - weight: - format: int32 - type: integer - type: object - type: array - requiredDuringSchedulingIgnoredDuringExecution: - properties: - nodeSelectorTerms: - items: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: - type: string - values: - items: + values: + items: + type: string + type: array + type: object + type: array + matchFields: + items: + properties: + key: type: string - type: array - type: object - type: array - matchFields: - items: - properties: - key: - type: string - operator: - type: string - values: - items: + operator: type: string - type: array - type: object - type: array - type: object - type: array - type: object - type: object - podAffinity: - properties: - preferredDuringSchedulingIgnoredDuringExecution: - items: - properties: - podAffinityTerm: - properties: - labelSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: + values: + items: type: string - values: - items: - type: string - type: array - type: object - type: array - matchLabels: - additionalProperties: - type: string + type: array type: object - type: object - namespaceSelector: - properties: - matchExpressions: - items: - properties: - key: + type: array + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + properties: + nodeSelectorTerms: + items: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: type: string - operator: + type: array + type: object + type: array + matchFields: + items: + properties: + key: + type: string + operator: + type: string + values: + items: type: string - values: - items: - type: string - type: array - type: object - type: array - matchLabels: - additionalProperties: - type: string + type: array type: object - type: object - namespaces: - items: - type: string - type: array - topologyKey: - type: string - type: object - weight: - format: int32 - type: integer + type: array + type: object + type: array type: object - type: array - requiredDuringSchedulingIgnoredDuringExecution: - items: - properties: - labelSelector: - properties: - matchExpressions: - items: + type: object + podAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + podAffinityTerm: + properties: + labelSelector: properties: - key: - type: string - operator: - type: string - values: + matchExpressions: items: - type: string + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object type: array + matchLabels: + additionalProperties: + type: string + type: object type: object - type: array - matchLabels: - additionalProperties: - type: string - type: object - type: object - namespaceSelector: - properties: - matchExpressions: - items: + namespaceSelector: properties: - key: - type: string - operator: - type: string - values: + matchExpressions: items: - type: string + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object type: array + matchLabels: + additionalProperties: + type: string + type: object type: object - type: array - matchLabels: - additionalProperties: + namespaces: + items: + type: string + type: array + topologyKey: type: string - type: object - type: object - namespaces: - items: - type: string - type: array - topologyKey: - type: string - type: object - type: array - type: object - podAntiAffinity: - properties: - preferredDuringSchedulingIgnoredDuringExecution: - items: - properties: - podAffinityTerm: - properties: - labelSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + items: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: type: string - values: - items: - type: string - type: array - type: object - type: array - matchLabels: - additionalProperties: - type: string + type: array type: object - type: object - namespaceSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: type: string - values: - items: - type: string - type: array - type: object - type: array - matchLabels: - additionalProperties: - type: string + type: array type: object - type: object - namespaces: - items: - type: string - type: array - topologyKey: + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: type: string - type: object - weight: - format: int32 - type: integer - type: object - type: array - requiredDuringSchedulingIgnoredDuringExecution: - items: - properties: - labelSelector: - properties: - matchExpressions: - items: + type: array + topologyKey: + type: string + type: object + type: array + type: object + podAntiAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + podAffinityTerm: + properties: + labelSelector: properties: - key: - type: string - operator: - type: string - values: + matchExpressions: items: - type: string + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object type: array + matchLabels: + additionalProperties: + type: string + type: object type: object - type: array - matchLabels: - additionalProperties: - type: string - type: object - type: object - namespaceSelector: - properties: - matchExpressions: - items: + namespaceSelector: properties: - key: - type: string - operator: - type: string - values: + matchExpressions: items: - type: string + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object type: array + matchLabels: + additionalProperties: + type: string + type: object type: object - type: array - matchLabels: - additionalProperties: + namespaces: + items: + type: string + type: array + topologyKey: type: string - type: object - type: object - namespaces: - items: + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + items: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: + type: string + type: array + topologyKey: type: string - type: array - topologyKey: - type: string - type: object - type: array - 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 - image: - description: Image define image details - type: string - nodeSelector: - additionalProperties: + type: object + type: array + 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 + image: + description: Image define image details 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 - type: integer - fsGroupChangePolicy: + nodeSelector: + additionalProperties: type: string - runAsGroup: - format: int64 - type: integer - runAsNonRoot: - type: boolean - runAsUser: - format: int64 - type: integer - seLinuxOptions: - properties: - level: - type: string - role: - type: string - type: - type: string - user: - type: string - type: object - seccompProfile: - properties: - localhostProfile: - type: string - type: - type: string - type: object - supplementalGroups: - items: + 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 type: integer - type: array - sysctls: - items: - properties: - name: - type: string - value: + fsGroupChangePolicy: + type: string + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: + type: string + role: + type: string + type: + type: string + user: type: string type: object - type: array - windowsOptions: - properties: - gmsaCredentialSpec: - type: string - gmsaCredentialSpecName: + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + type: object + supplementalGroups: + items: + format: int64 + type: integer + type: array + sysctls: + items: + properties: + name: + type: string + value: + type: string + type: object + type: array + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + 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: + limits: + additionalProperties: type: string - hostProcess: - type: boolean - runAsUserName: + type: object + requests: + additionalProperties: 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: 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 - type: array - resources: - description: Resources holds resource requests & limits for container - properties: - limits: - additionalProperties: - type: string - type: object - requests: - additionalProperties: + securityContext: + description: PodSecurityContext holds pod-level security attributes and common container settings. + properties: + allowPrivilegeEscalation: + type: boolean + capabilities: + properties: + add: + items: + type: string + type: array + drop: + items: + type: string + type: array + type: object + privileged: + type: boolean + procMount: type: string - 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 - capabilities: - properties: - add: - items: + readOnlyRootFilesystem: + type: boolean + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: type: string - type: array - drop: - items: + role: type: string - type: array - type: object - privileged: - type: boolean - procMount: - type: string - readOnlyRootFilesystem: - type: boolean - runAsGroup: - format: int64 - type: integer - runAsNonRoot: - type: boolean - runAsUser: - format: int64 - type: integer - seLinuxOptions: - properties: - level: - type: string - role: - type: string - type: - type: string - user: - type: string - type: object - seccompProfile: + type: + type: string + user: + type: string + type: object + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + type: object + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + type: string + 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: - localhostProfile: - type: string - type: + effect: type: string - type: object - windowsOptions: - properties: - gmsaCredentialSpec: + key: type: string - gmsaCredentialSpecName: + operator: type: string - hostProcess: - type: boolean - runAsUserName: + tolerationSeconds: + format: int64 + type: integer + value: type: string 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: + type: array + type: object + gpu: + description: GPU defines templates for GPU jobs + properties: + affinity: + description: Affinity defines scheduling constraints for workload properties: - effect: - type: string - key: - type: string - operator: - type: string - tolerationSeconds: - format: int64 - type: integer - value: - type: string - type: object - type: array - type: object - description: Prediction defines template for the prediction job - type: object - training: - additionalProperties: - properties: - affinity: - description: Affinity defines scheduling constraints for workload - properties: - nodeAffinity: - properties: - preferredDuringSchedulingIgnoredDuringExecution: - items: + nodeAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + preference: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchFields: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: properties: - preference: - properties: - matchExpressions: - items: + nodeSelectorTerms: + items: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchFields: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + type: object + type: array + type: object + type: object + podAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + podAffinityTerm: + properties: + labelSelector: properties: - key: - type: string - operator: - type: string - values: + matchExpressions: items: - type: string + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object type: array + matchLabels: + additionalProperties: + type: string + type: object type: object - type: array - matchFields: - items: + namespaceSelector: properties: - key: - type: string - operator: - type: string - values: + matchExpressions: items: - type: string + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object type: array + matchLabels: + additionalProperties: + type: string + type: object type: object - type: array - type: object - weight: - format: int32 - type: integer - type: object - type: array - requiredDuringSchedulingIgnoredDuringExecution: - properties: - nodeSelectorTerms: - items: - properties: - matchExpressions: - items: + namespaces: + items: + type: string + type: array + topologyKey: + type: string + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + items: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: + type: string + type: array + topologyKey: + type: string + type: object + type: array + type: object + podAntiAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + podAffinityTerm: + properties: + labelSelector: properties: - key: - type: string - operator: - type: string - values: + matchExpressions: items: - type: string + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object type: array + matchLabels: + additionalProperties: + type: string + type: object type: object - type: array - matchFields: - items: + namespaceSelector: properties: - key: - type: string - operator: - type: string - values: + matchExpressions: items: - type: string + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object type: array + matchLabels: + additionalProperties: + type: string + type: object type: object - type: array - type: object - type: array - type: object - type: object - podAffinity: - properties: - preferredDuringSchedulingIgnoredDuringExecution: - items: - properties: - podAffinityTerm: - properties: - labelSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: + namespaces: + items: + type: string + type: array + topologyKey: + type: string + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + items: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: type: string - values: - items: - type: string - type: array - type: object - type: array - matchLabels: - additionalProperties: - type: string + type: array type: object - type: object - namespaceSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: type: string - values: - items: - type: string - type: array - type: object - type: array - matchLabels: - additionalProperties: - type: string + type: array type: object - type: object - namespaces: - items: - type: string - type: array - topologyKey: + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: type: string - type: object - weight: - format: int32 - type: integer - type: object - type: array - requiredDuringSchedulingIgnoredDuringExecution: - items: + type: array + topologyKey: + type: string + type: object + type: array + 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 + image: + description: Image define image details + type: string + 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 + type: integer + fsGroupChangePolicy: + type: string + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: + type: string + role: + type: string + type: + type: string + user: + type: string + type: object + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + type: object + supplementalGroups: + items: + format: int64 + type: integer + type: array + sysctls: + items: + properties: + name: + type: string + value: + type: string + type: object + type: array + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + 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: + limits: + additionalProperties: + type: string + type: object + requests: + additionalProperties: + type: string + 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 + capabilities: + properties: + add: + items: + type: string + type: array + drop: + items: + type: string + type: array + type: object + privileged: + type: boolean + procMount: + type: string + readOnlyRootFilesystem: + type: boolean + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: + type: string + role: + type: string + type: + type: string + user: + type: string + type: object + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + type: object + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + type: string + 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: + type: string + key: + type: string + operator: + type: string + tolerationSeconds: + format: int64 + type: integer + value: + type: string + type: object + type: array + type: object + type: object + training: + description: Training defines template for the training job + properties: + cpu: + description: CPU defines templates for CPU jobs + properties: + affinity: + description: Affinity defines scheduling constraints for workload + properties: + nodeAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + preference: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchFields: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: properties: - labelSelector: - properties: - matchExpressions: - items: + nodeSelectorTerms: + items: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchFields: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + type: object + type: array + type: object + type: object + podAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + podAffinityTerm: + properties: + labelSelector: properties: - key: - type: string - operator: - type: string - values: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: + type: string + type: array + topologyKey: + type: string + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + items: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: + type: string + type: array + topologyKey: + type: string + type: object + type: array + type: object + podAntiAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + podAffinityTerm: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: + type: string + type: array + topologyKey: + type: string + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + items: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: + type: string + type: array + topologyKey: + type: string + type: object + type: array + 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 + image: + description: Image define image details + type: string + 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 + type: integer + fsGroupChangePolicy: + type: string + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: + type: string + role: + type: string + type: + type: string + user: + type: string + type: object + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + type: object + supplementalGroups: + items: + format: int64 + type: integer + type: array + sysctls: + items: + properties: + name: + type: string + value: + type: string + type: object + type: array + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + 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: + limits: + additionalProperties: + type: string + type: object + requests: + additionalProperties: + type: string + 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 + capabilities: + properties: + add: + items: + type: string + type: array + drop: + items: + type: string + type: array + type: object + privileged: + type: boolean + procMount: + type: string + readOnlyRootFilesystem: + type: boolean + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: + type: string + role: + type: string + type: + type: string + user: + type: string + type: object + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + type: object + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + type: string + 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: + type: string + key: + type: string + operator: + type: string + tolerationSeconds: + format: int64 + type: integer + value: + type: string + type: object + type: array + type: object + gpu: + description: GPU defines templates for GPU jobs + properties: + affinity: + description: Affinity defines scheduling constraints for workload + properties: + nodeAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + preference: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchFields: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + properties: + nodeSelectorTerms: + items: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchFields: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + type: object + type: array + type: object + type: object + podAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + podAffinityTerm: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object type: array + matchLabels: + additionalProperties: + type: string + type: object type: object - type: array - matchLabels: - additionalProperties: - type: string - type: object - type: object - namespaceSelector: - properties: - matchExpressions: - items: + namespaceSelector: properties: - key: - type: string - operator: - type: string - values: + matchExpressions: items: - type: string + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object type: array + matchLabels: + additionalProperties: + type: string + type: object type: object - type: array - matchLabels: - additionalProperties: + namespaces: + items: + type: string + type: array + topologyKey: type: string - type: object - type: object - namespaces: - items: - type: string - type: array - topologyKey: - type: string - type: object - type: array - type: object - podAntiAffinity: - properties: - preferredDuringSchedulingIgnoredDuringExecution: - items: - properties: - podAffinityTerm: - properties: - labelSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + items: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: type: string - values: - items: - type: string - type: array - type: object - type: array - matchLabels: - additionalProperties: - type: string + type: array type: object - type: object - namespaceSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: type: string - values: - items: - type: string - type: array - type: object - type: array - matchLabels: - additionalProperties: - type: string + type: array type: object - type: object - namespaces: - items: - type: string - type: array - topologyKey: + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: type: string - type: object - weight: - format: int32 - type: integer - type: object - type: array - requiredDuringSchedulingIgnoredDuringExecution: - items: - properties: - labelSelector: - properties: - matchExpressions: - items: + type: array + topologyKey: + type: string + type: object + type: array + type: object + podAntiAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + podAffinityTerm: + properties: + labelSelector: properties: - key: - type: string - operator: - type: string - values: + matchExpressions: items: - type: string + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object type: array + matchLabels: + additionalProperties: + type: string + type: object type: object - type: array - matchLabels: - additionalProperties: - type: string - type: object - type: object - namespaceSelector: - properties: - matchExpressions: - items: + namespaceSelector: properties: - key: - type: string - operator: - type: string - values: + matchExpressions: items: - type: string + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object type: array + matchLabels: + additionalProperties: + type: string + type: object type: object - type: array - matchLabels: - additionalProperties: + namespaces: + items: + type: string + type: array + topologyKey: type: string - type: object - type: object - namespaces: - items: + type: object + weight: + format: int32 + type: integer + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + items: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + namespaces: + items: + type: string + type: array + topologyKey: type: string - type: array - topologyKey: - type: string - type: object - type: array - 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 - image: - description: Image define image details - type: string - nodeSelector: - additionalProperties: + type: object + type: array + 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 + image: + description: Image define image details 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 - type: integer - fsGroupChangePolicy: + nodeSelector: + additionalProperties: type: string - runAsGroup: - format: int64 - type: integer - runAsNonRoot: - type: boolean - runAsUser: - format: int64 - type: integer - seLinuxOptions: - properties: - level: - type: string - role: - type: string - type: - type: string - user: - type: string - type: object - seccompProfile: - properties: - localhostProfile: - type: string - type: - type: string - type: object - supplementalGroups: - items: + 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 + type: integer + fsGroupChangePolicy: + type: string + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: format: int64 type: integer - type: array - sysctls: - items: + seLinuxOptions: properties: - name: + level: type: string - value: + role: + type: string + type: + type: string + user: type: string type: object - type: array - windowsOptions: - properties: - gmsaCredentialSpec: - type: string - gmsaCredentialSpecName: + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + type: object + supplementalGroups: + items: + format: int64 + type: integer + type: array + sysctls: + items: + properties: + name: + type: string + value: + type: string + type: object + type: array + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + 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: + limits: + additionalProperties: type: string - hostProcess: - type: boolean - runAsUserName: + type: object + requests: + additionalProperties: 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: 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 - type: array - resources: - description: Resources holds resource requests & limits for container - properties: - limits: - additionalProperties: - type: string - type: object - requests: - additionalProperties: + securityContext: + description: PodSecurityContext holds pod-level security attributes and common container settings. + properties: + allowPrivilegeEscalation: + type: boolean + capabilities: + properties: + add: + items: + type: string + type: array + drop: + items: + type: string + type: array + type: object + privileged: + type: boolean + procMount: type: string - 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 - capabilities: - properties: - add: - items: + readOnlyRootFilesystem: + type: boolean + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: type: string - type: array - drop: - items: + role: type: string - type: array - type: object - privileged: - type: boolean - procMount: - type: string - readOnlyRootFilesystem: - type: boolean - runAsGroup: - format: int64 - type: integer - runAsNonRoot: - type: boolean - runAsUser: - format: int64 - type: integer - seLinuxOptions: - properties: - level: - type: string - role: - type: string - type: - type: string - user: - type: string - type: object - seccompProfile: + type: + type: string + user: + type: string + type: object + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + type: object + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + type: string + 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: - localhostProfile: - type: string - type: + effect: type: string - type: object - windowsOptions: - properties: - gmsaCredentialSpec: + key: type: string - gmsaCredentialSpecName: + operator: type: string - hostProcess: - type: boolean - runAsUserName: + tolerationSeconds: + format: int64 + type: integer + value: type: string 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: - type: string - key: - type: string - operator: - type: string - tolerationSeconds: - format: int64 - type: integer - value: - type: string - type: object - type: array - type: object - description: Training defines template for the training job + type: array + type: object type: object type: object metadataService: diff --git a/pkg/util/labels.go b/pkg/util/labels.go new file mode 100644 index 000000000..853690364 --- /dev/null +++ b/pkg/util/labels.go @@ -0,0 +1,30 @@ +// +// 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 util + +import ( + meta "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func ExtractLabel(obj meta.Object, label string) (string, bool) { + v, ok := obj.GetLabels()[label] + return v, ok +} From cd7b90b045083bbcd0fefbcf024de1c158a403e8 Mon Sep 17 00:00:00 2001 From: ajanikow <12255597+ajanikow@users.noreply.github.com> Date: Mon, 18 Dec 2023 09:35:15 +0000 Subject: [PATCH 5/7] Iter --- pkg/apis/ml/v1alpha1/extension_spec_job.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/apis/ml/v1alpha1/extension_spec_job.go b/pkg/apis/ml/v1alpha1/extension_spec_job.go index 1a33fa76d..65ef82df3 100644 --- a/pkg/apis/ml/v1alpha1/extension_spec_job.go +++ b/pkg/apis/ml/v1alpha1/extension_spec_job.go @@ -41,11 +41,15 @@ type ArangoMLJobsTemplates struct { } func (a *ArangoMLJobsTemplates) GetJobTemplates(jobType JobType) *ArangoMLJobTemplates { + if a == nil { + return nil + } + switch jobType { case MLJobTrainingType: - return a.Prediction - case MLJobPredictionType: return a.Training + case MLJobPredictionType: + return a.Prediction default: return nil } From 35b7045949fe0edc0a635d60004452170448f8db Mon Sep 17 00:00:00 2001 From: jwierzbo Date: Mon, 18 Dec 2023 19:45:36 +0800 Subject: [PATCH 6/7] MLConditions - rename --- docs/api/ArangoMLBatchJob.V1Alpha1.md | 6 +++--- docs/api/ArangoMLCronJob.V1Alpha1.md | 6 +++--- pkg/apis/ml/v1alpha1/batchjob_status.go | 6 +++--- pkg/apis/ml/v1alpha1/cronjob_status.go | 6 +++--- pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go | 8 ++++---- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/api/ArangoMLBatchJob.V1Alpha1.md b/docs/api/ArangoMLBatchJob.V1Alpha1.md index 6e6218bba..38480bfb2 100644 --- a/docs/api/ArangoMLBatchJob.V1Alpha1.md +++ b/docs/api/ArangoMLBatchJob.V1Alpha1.md @@ -20,11 +20,11 @@ Links: *** -### .status.conditions +### .status.mlConditions -Type: `api.Conditions` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/batchjob_status.go#L33) +Type: `api.MLConditions` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/batchjob_status.go#L33) -Conditions specific to the entire batch job +MLConditions specific to the entire batch job *** diff --git a/docs/api/ArangoMLCronJob.V1Alpha1.md b/docs/api/ArangoMLCronJob.V1Alpha1.md index 4b03ee2c3..899cd4731 100644 --- a/docs/api/ArangoMLCronJob.V1Alpha1.md +++ b/docs/api/ArangoMLCronJob.V1Alpha1.md @@ -20,11 +20,11 @@ Links: *** -### .status.conditions +### .status.mlConditions -Type: `api.Conditions` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/cronjob_status.go#L33) +Type: `api.MLConditions` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/cronjob_status.go#L33) -Conditions specific to the entire cron job +MLConditions specific to the entire cron job *** diff --git a/pkg/apis/ml/v1alpha1/batchjob_status.go b/pkg/apis/ml/v1alpha1/batchjob_status.go index baa219de1..6824ac5dc 100644 --- a/pkg/apis/ml/v1alpha1/batchjob_status.go +++ b/pkg/apis/ml/v1alpha1/batchjob_status.go @@ -28,9 +28,9 @@ import ( ) type ArangoMLBatchJobStatus struct { - // Conditions specific to the entire batch job - // +doc/type: api.Conditions - Conditions api.ConditionList `json:"conditions,omitempty"` + // MLConditions specific to the entire batch job + // +doc/type: api.MLConditions + MLConditions api.ConditionList `json:"mlConditions,omitempty"` // +doc/type: batch.JobStatus // +doc/link: Kubernetes Documentation|https://godoc.org/k8s.io/api/batch/v1#JobStatus diff --git a/pkg/apis/ml/v1alpha1/cronjob_status.go b/pkg/apis/ml/v1alpha1/cronjob_status.go index b929cfb8d..748a49dcd 100644 --- a/pkg/apis/ml/v1alpha1/cronjob_status.go +++ b/pkg/apis/ml/v1alpha1/cronjob_status.go @@ -28,9 +28,9 @@ import ( ) type ArangoMLCronJobStatus struct { - // Conditions specific to the entire cron job - // +doc/type: api.Conditions - Conditions api.ConditionList `json:"conditions,omitempty"` + // MLConditions specific to the entire cron job + // +doc/type: api.MLConditions + MLConditions api.ConditionList `json:"mlConditions,omitempty"` // +doc/type: batch.CronJobStatus // +doc/link: Kubernetes Documentation|https://godoc.org/k8s.io/api/batch/v1#CronJobStatus diff --git a/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go index e4b67b261..29dac0236 100644 --- a/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go @@ -118,8 +118,8 @@ func (in *ArangoMLBatchJobSpec) DeepCopy() *ArangoMLBatchJobSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ArangoMLBatchJobStatus) DeepCopyInto(out *ArangoMLBatchJobStatus) { *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions + if in.MLConditions != nil { + in, out := &in.MLConditions, &out.MLConditions *out = make(deploymentv1.ConditionList, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) @@ -233,8 +233,8 @@ func (in *ArangoMLCronJobSpec) DeepCopy() *ArangoMLCronJobSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ArangoMLCronJobStatus) DeepCopyInto(out *ArangoMLCronJobStatus) { *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions + if in.MLConditions != nil { + in, out := &in.MLConditions, &out.MLConditions *out = make(deploymentv1.ConditionList, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) From 787dcac439857e348476555700edb60c66fdfd38 Mon Sep 17 00:00:00 2001 From: jwierzbo Date: Mon, 18 Dec 2023 21:24:37 +0800 Subject: [PATCH 7/7] ArangoMLExtensionTemplate --- pkg/apis/ml/v1alpha1/conditions.go | 14 ++++++-- pkg/apis/ml/v1alpha1/extension_conditions.go | 36 ------------------- pkg/apis/ml/v1alpha1/extension_spec.go | 6 ++-- pkg/apis/ml/v1alpha1/extension_spec_job.go | 14 ++++---- pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go | 14 ++++---- .../crds/ml-extension.schema.generated.yaml | 2 +- 6 files changed, 30 insertions(+), 56 deletions(-) delete mode 100644 pkg/apis/ml/v1alpha1/extension_conditions.go diff --git a/pkg/apis/ml/v1alpha1/conditions.go b/pkg/apis/ml/v1alpha1/conditions.go index 6f9ab60e1..f8f372616 100644 --- a/pkg/apis/ml/v1alpha1/conditions.go +++ b/pkg/apis/ml/v1alpha1/conditions.go @@ -23,6 +23,16 @@ package v1alpha1 import api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" const ( - ReadyCondition api.ConditionType = "Ready" - SpecValidCondition api.ConditionType = "SpecValid" + ReadyCondition api.ConditionType = "Ready" + SpecValidCondition api.ConditionType = "SpecValid" + ExtensionFoundCondition api.ConditionType = "ExtensionFound" + ExtensionStorageFoundCondition api.ConditionType = "StorageFound" + ExtensionDeploymentFoundCondition api.ConditionType = "DeploymentFound" + ExtensionBootstrapCompletedCondition api.ConditionType = "BootstrapCompleted" + ExtensionMetadataServiceValidCondition api.ConditionType = "MetadataServiceValid" + ExtensionServiceAccountReadyCondition api.ConditionType = "ServiceAccountReady" + ExtensionStatefulSetReadyCondition api.ConditionType = "ExtensionDeploymentReady" + LicenseValidCondition api.ConditionType = "LicenseValid" + CronJobSyncedCondition api.ConditionType = "CronJobSynced" + BatchJobSyncedCondition api.ConditionType = "BatchJobSynced" ) diff --git a/pkg/apis/ml/v1alpha1/extension_conditions.go b/pkg/apis/ml/v1alpha1/extension_conditions.go deleted file mode 100644 index cc45e9260..000000000 --- a/pkg/apis/ml/v1alpha1/extension_conditions.go +++ /dev/null @@ -1,36 +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 v1alpha1 - -import api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" - -const ( - MLExtensionFoundCondition api.ConditionType = "MLExtensionFound" - ExtensionStorageFoundCondition api.ConditionType = "StorageFound" - ExtensionDeploymentFoundCondition api.ConditionType = "DeploymentFound" - ExtensionBootstrapCompletedCondition api.ConditionType = "BootstrapCompleted" - ExtensionMetadataServiceValidCondition api.ConditionType = "MetadataServiceValid" - ExtensionServiceAccountReadyCondition api.ConditionType = "ServiceAccountReady" - ExtensionStatefulSetReadyCondition api.ConditionType = "ExtensionDeploymentReady" - LicenseValidCondition api.ConditionType = "LicenseValid" - CronJobSyncedCondition api.ConditionType = "CronJobSynced" - BatchJobSyncedCondition api.ConditionType = "BatchJobSynced" -) diff --git a/pkg/apis/ml/v1alpha1/extension_spec.go b/pkg/apis/ml/v1alpha1/extension_spec.go index 37118d2df..0ce6f8927 100644 --- a/pkg/apis/ml/v1alpha1/extension_spec.go +++ b/pkg/apis/ml/v1alpha1/extension_spec.go @@ -36,8 +36,8 @@ type ArangoMLExtensionSpec struct { // Image defines default image used for the extension *sharedApi.Image `json:",inline"` - // ArangoMLExtensionTemplateSpec define Init job specification - Init *ArangoMLExtensionTemplateSpec `json:"init,omitempty"` + // ArangoMLExtensionTemplate define Init job specification + Init *ArangoMLExtensionTemplate `json:"init,omitempty"` // Deployment specifies how the ML extension will be deployed into cluster Deployment *ArangoMLExtensionSpecDeployment `json:"deployment,omitempty"` @@ -62,7 +62,7 @@ func (a *ArangoMLExtensionSpec) GetImage() *sharedApi.Image { return a.Image } -func (a *ArangoMLExtensionSpec) GetInit() *ArangoMLExtensionTemplateSpec { +func (a *ArangoMLExtensionSpec) GetInit() *ArangoMLExtensionTemplate { if a == nil || a.Init == nil { return nil } diff --git a/pkg/apis/ml/v1alpha1/extension_spec_job.go b/pkg/apis/ml/v1alpha1/extension_spec_job.go index 65ef82df3..772f444d8 100644 --- a/pkg/apis/ml/v1alpha1/extension_spec_job.go +++ b/pkg/apis/ml/v1alpha1/extension_spec_job.go @@ -75,13 +75,13 @@ const ( type ArangoMLJobTemplates struct { // CPU defines templates for CPU jobs - CPU *ArangoMLExtensionTemplateSpec `json:"cpu,omitempty"` + CPU *ArangoMLExtensionTemplate `json:"cpu,omitempty"` // GPU defines templates for GPU jobs - GPU *ArangoMLExtensionTemplateSpec `json:"gpu,omitempty"` + GPU *ArangoMLExtensionTemplate `json:"gpu,omitempty"` } -func (a *ArangoMLJobTemplates) GetJobTemplateSpec(scheduleType JobScheduleType) *ArangoMLExtensionTemplateSpec { +func (a *ArangoMLJobTemplates) GetJobTemplateSpec(scheduleType JobScheduleType) *ArangoMLExtensionTemplate { switch scheduleType { case MLJobScheduleCPU: return a.CPU @@ -103,7 +103,7 @@ func (a *ArangoMLJobTemplates) Validate() error { ) } -type ArangoMLExtensionTemplateSpec struct { +type ArangoMLExtensionTemplate struct { // PodTemplate keeps the information about Pod configuration *sharedApi.PodTemplate `json:",inline"` @@ -111,7 +111,7 @@ type ArangoMLExtensionTemplateSpec struct { *sharedApi.ContainerTemplate `json:",inline"` } -func (a *ArangoMLExtensionTemplateSpec) GetPodTemplate() *sharedApi.PodTemplate { +func (a *ArangoMLExtensionTemplate) GetPodTemplate() *sharedApi.PodTemplate { if a == nil { return nil } @@ -119,7 +119,7 @@ func (a *ArangoMLExtensionTemplateSpec) GetPodTemplate() *sharedApi.PodTemplate return a.PodTemplate } -func (a *ArangoMLExtensionTemplateSpec) GetContainerTemplate() *sharedApi.ContainerTemplate { +func (a *ArangoMLExtensionTemplate) GetContainerTemplate() *sharedApi.ContainerTemplate { if a == nil { return nil } @@ -127,7 +127,7 @@ func (a *ArangoMLExtensionTemplateSpec) GetContainerTemplate() *sharedApi.Contai return a.ContainerTemplate } -func (a *ArangoMLExtensionTemplateSpec) Validate() error { +func (a *ArangoMLExtensionTemplate) Validate() error { if a == nil { return nil } diff --git a/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go index 29dac0236..df1201f5d 100644 --- a/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go @@ -344,7 +344,7 @@ func (in *ArangoMLExtensionSpec) DeepCopyInto(out *ArangoMLExtensionSpec) { } if in.Init != nil { in, out := &in.Init, &out.Init - *out = new(ArangoMLExtensionTemplateSpec) + *out = new(ArangoMLExtensionTemplate) (*in).DeepCopyInto(*out) } if in.Deployment != nil { @@ -612,7 +612,7 @@ func (in *ArangoMLExtensionStatusMetadataServiceLocal) DeepCopy() *ArangoMLExten } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ArangoMLExtensionTemplateSpec) DeepCopyInto(out *ArangoMLExtensionTemplateSpec) { +func (in *ArangoMLExtensionTemplate) DeepCopyInto(out *ArangoMLExtensionTemplate) { *out = *in if in.PodTemplate != nil { in, out := &in.PodTemplate, &out.PodTemplate @@ -627,12 +627,12 @@ func (in *ArangoMLExtensionTemplateSpec) DeepCopyInto(out *ArangoMLExtensionTemp return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoMLExtensionTemplateSpec. -func (in *ArangoMLExtensionTemplateSpec) DeepCopy() *ArangoMLExtensionTemplateSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoMLExtensionTemplate. +func (in *ArangoMLExtensionTemplate) DeepCopy() *ArangoMLExtensionTemplate { if in == nil { return nil } - out := new(ArangoMLExtensionTemplateSpec) + out := new(ArangoMLExtensionTemplate) in.DeepCopyInto(out) return out } @@ -642,12 +642,12 @@ func (in *ArangoMLJobTemplates) DeepCopyInto(out *ArangoMLJobTemplates) { *out = *in if in.CPU != nil { in, out := &in.CPU, &out.CPU - *out = new(ArangoMLExtensionTemplateSpec) + *out = new(ArangoMLExtensionTemplate) (*in).DeepCopyInto(*out) } if in.GPU != nil { in, out := &in.GPU, &out.GPU - *out = new(ArangoMLExtensionTemplateSpec) + *out = new(ArangoMLExtensionTemplate) (*in).DeepCopyInto(*out) } return diff --git a/pkg/crd/crds/ml-extension.schema.generated.yaml b/pkg/crd/crds/ml-extension.schema.generated.yaml index ee3f96063..5a061cd03 100644 --- a/pkg/crd/crds/ml-extension.schema.generated.yaml +++ b/pkg/crd/crds/ml-extension.schema.generated.yaml @@ -705,7 +705,7 @@ v1alpha1: description: Image define image details type: string init: - description: ArangoMLExtensionTemplateSpec define Init job specification + description: ArangoMLExtensionTemplate define Init job specification properties: affinity: description: Affinity defines scheduling constraints for workload