From 49da4b246400bcea1caad191f210e5c2289856f3 Mon Sep 17 00:00:00 2001 From: jwierzbo Date: Thu, 14 Dec 2023 23:26:47 +0100 Subject: [PATCH] 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 {