Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] [ML] Pod & Container Config #1533

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- (Improvement) (ML) CronJob status update
- (Improvement) (ML) Job Sidecar Shutdown
- (Feature) (ML) Handler for Extension StatefulSet and Service
- (Feature) (ML) Pod & Container Config

## [1.2.35](https://github.com/arangodb/kube-arangodb/tree/1.2.35) (2023-11-06)
- (Maintenance) Update go-driver to v1.6.0, update IsNotFound() checks
Expand Down
127 changes: 124 additions & 3 deletions docs/api/ArangoMLExtension.V1Alpha1.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PullSecrets define Secrets used to pull Image from registry

### .spec.deployment.prediction.resources

Type: `core.ResourceRequirements` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/resources.go#L33)</sup>
Type: `core.ResourceRequirements` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/resources.go#L34)</sup>

Resources holds resource requests & limits for container

Expand Down Expand Up @@ -83,7 +83,7 @@ PullSecrets define Secrets used to pull Image from registry

### .spec.deployment.project.resources

Type: `core.ResourceRequirements` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/resources.go#L33)</sup>
Type: `core.ResourceRequirements` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/resources.go#L34)</sup>

Resources holds resource requests & limits for container

Expand Down Expand Up @@ -155,7 +155,7 @@ PullSecrets define Secrets used to pull Image from registry

### .spec.deployment.training.resources

Type: `core.ResourceRequirements` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/resources.go#L33)</sup>
Type: `core.ResourceRequirements` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/resources.go#L34)</sup>

Resources holds resource requests & limits for container

Expand All @@ -172,6 +172,48 @@ Image define image details

***

### .spec.init.affinity

Type: `core.Affinity` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L37)</sup>

Affinity defines scheduling constraints for workload

Links:
* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity)

***

### .spec.init.hostIPC

Type: `boolean` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L33)</sup>

HostIPC defines to use the host's ipc namespace.

Default Value: `false`

***

### .spec.init.hostNetwork

Type: `boolean` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L27)</sup>

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.init.hostPID

Type: `boolean` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L30)</sup>

HostPID define to use the host's pid namespace.

Default Value: `false`

***

### .spec.init.image

Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L31)</sup>
Expand All @@ -180,6 +222,28 @@ Image define image details

***

### .spec.init.nodeSelector

Type: `object` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L32)</sup>

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.init.podSecurityContext

Type: `core.PodSecurityContext` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_pod.go#L29)</sup>

PodSecurityContext holds pod-level security attributes and common container settings.

Links:
* [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)

***

### .spec.init.pullPolicy

Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/image.go#L35)</sup>
Expand All @@ -198,6 +262,63 @@ PullSecrets define Secrets used to pull Image from registry

***

### .spec.init.resources

Type: `core.ResourceRequirements` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/resources.go#L34)</sup>

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.init.schedulerName

Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L47)</sup>

SchedulerName specifies, the pod will be dispatched by specified scheduler.
If not specified, the pod will be dispatched by default scheduler.

Default Value: `""`

***

### .spec.init.securityContext

Type: `core.SecurityContext` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_container.go#L29)</sup>

PodSecurityContext holds pod-level security attributes and common container settings.

Links:
* [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)

***

### .spec.init.shareProcessNamespace

Type: `boolean` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L39)</sup>

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.init.tolerations

Type: `[]core.Toleration` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L42)</sup>

Tolerations defines tolerations

Links:
* [Kubernetes docs](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)

***

### .spec.metadataService.local.arangoMLFeatureStore

Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/extension_spec_metadata_service.go#L65)</sup>
Expand Down
13 changes: 12 additions & 1 deletion docs/api/ArangoMLStorage.V1Alpha1.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ PullSecrets define Secrets used to pull Image from registry

### .spec.mode.sidecar.resources

Type: `core.ResourceRequirements` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/resources.go#L33)</sup>
Type: `core.ResourceRequirements` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/resources.go#L34)</sup>

Resources holds resource requests & limits for container

Expand All @@ -145,6 +145,17 @@ Links:

***

### .spec.mode.sidecar.securityContext

Type: `core.SecurityContext` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_container.go#L29)</sup>

PodSecurityContext holds pod-level security attributes and common container settings.

Links:
* [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)

***

### .spec.mode.sidecar.shutdownListenPort

Type: `integer` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/storage_spec_mode_sidecar.go#L36)</sup>
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/ml/v1alpha1/extension_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (a *ArangoMLExtensionSpec) Validate() error {
shared.PrefixResourceErrors("storage", shared.ValidateRequired(a.GetStorage(), func(obj sharedApi.Object) error { return obj.Validate() })),
a.GetImage().Validate(),
shared.PrefixResourceErrors("init", a.GetInit().Validate()),
shared.ValidateAnyNotNil(".image or .init.image needs to be specified", a.GetImage(), a.GetInit().GetImage()),
shared.ValidateAnyNotNil(".image or .init.image needs to be specified", a.GetImage(), a.GetInit().GetContainerTemplate().GetImage()),
shared.PrefixResourceErrors("deployment", a.GetDeployment().Validate()),
))
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,36 @@ import (
)

type ArangoMLExtensionSpecInit struct {
// Image define default image used for the init job
*sharedApi.Image `json:",inline"`
// PodTemplate keeps the information about Pod configuration
*sharedApi.PodTemplate `json:",inline"`

// ContainerTemplate Keeps the information about Container configuration
*sharedApi.ContainerTemplate `json:",inline"`
}

func (a *ArangoMLExtensionSpecInit) GetImage() *sharedApi.Image {
if a == nil || a.Image == nil {
func (a *ArangoMLExtensionSpecInit) GetPodTemplate() *sharedApi.PodTemplate {
if a == nil {
return nil
}

return a.Image
return a.PodTemplate
}

func (a *ArangoMLExtensionSpecInit) GetContainerTemplate() *sharedApi.ContainerTemplate {
if a == nil {
return nil
}

return a.ContainerTemplate
}

func (a *ArangoMLExtensionSpecInit) Validate() error {
if a == nil {
return nil
}

return shared.WithErrors(
a.GetImage().Validate(),
a.GetPodTemplate().Validate(),
a.GetContainerTemplate().Validate(),
)
}
23 changes: 6 additions & 17 deletions pkg/apis/ml/v1alpha1/storage_spec_mode_sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,16 @@ type ArangoMLStorageSpecModeSidecar struct {
// +doc/default: 9202
ShutdownListenPort *uint16 `json:"shutdownListenPort,omitempty"`

// Image define default image used for the extension
*sharedApi.Image `json:",inline"`

// Resources holds resource requests & limits for sidecar container
*sharedApi.Resources `json:",inline"`
}

func (s *ArangoMLStorageSpecModeSidecar) GetImage() *sharedApi.Image {
if s == nil || s.Image == nil {
return nil
}

return s.Image
// ContainerTemplate Keeps the information about Container configuration
*sharedApi.ContainerTemplate `json:",inline"`
}

func (s *ArangoMLStorageSpecModeSidecar) GetResources() *sharedApi.Resources {
if s == nil || s.Resources == nil {
func (s *ArangoMLStorageSpecModeSidecar) GetContainerTemplate() *sharedApi.ContainerTemplate {
if s == nil || s.ContainerTemplate == nil {
return nil
}

return s.Resources
return s.ContainerTemplate
}

func (s *ArangoMLStorageSpecModeSidecar) Validate() error {
Expand All @@ -73,7 +62,7 @@ func (s *ArangoMLStorageSpecModeSidecar) Validate() error {
err = append(err, shared.PrefixResourceErrors("shutdownListenPort", errors.Newf("must be positive")))
}

err = append(err, s.GetResources().Validate())
err = append(err, s.GetContainerTemplate().Validate())

return shared.WithErrors(err...)
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/apis/ml/v1alpha1/storage_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func Test_ArangoMLStorageSpec(t *testing.T) {
core.ResourceMemory: resource.MustParse("128Mi"),
},
}
s.Mode.Sidecar.ContainerTemplate = &sharedApi.ContainerTemplate{}
s.Mode.Sidecar.Resources = &sharedApi.Resources{Resources: &assignedRequirements}

expectedRequirements := core.ResourceRequirements{
Expand All @@ -76,7 +77,7 @@ func Test_ArangoMLStorageSpec(t *testing.T) {
},
}

actualRequirements := s.Mode.Sidecar.GetResources().With(core.ResourceRequirements{
actualRequirements := s.Mode.Sidecar.GetResources().With(&sharedApi.Resources{Resources: &core.ResourceRequirements{
Limits: core.ResourceList{
core.ResourceCPU: resource.MustParse("100m"),
core.ResourceMemory: resource.MustParse("128Mi"),
Expand All @@ -85,7 +86,7 @@ func Test_ArangoMLStorageSpec(t *testing.T) {
core.ResourceCPU: resource.MustParse("200m"),
core.ResourceMemory: resource.MustParse("256Mi"),
},
})
require.Equal(t, expectedRequirements, actualRequirements)
}})
require.Equal(t, expectedRequirements, *actualRequirements.GetResources())
})
}
22 changes: 11 additions & 11 deletions pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading