Skip to content

Commit 041bae8

Browse files
[Feature] [ML] Pod & Container Config (#1533)
Co-authored-by: Nikita Vaniasin <nikita.vanyasin@gmail.com>
1 parent cff60f2 commit 041bae8

22 files changed

+1398
-48
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
- (Improvement) (ML) CronJob status update
3333
- (Improvement) (ML) Job Sidecar Shutdown
3434
- (Feature) (ML) Handler for Extension StatefulSet and Service
35+
- (Feature) (ML) Pod & Container Config
3536

3637
## [1.2.35](https://github.com/arangodb/kube-arangodb/tree/1.2.35) (2023-11-06)
3738
- (Maintenance) Update go-driver to v1.6.0, update IsNotFound() checks

docs/api/ArangoMLExtension.V1Alpha1.md

Lines changed: 124 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PullSecrets define Secrets used to pull Image from registry
3838

3939
### .spec.deployment.prediction.resources
4040

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

4343
Resources holds resource requests & limits for container
4444

@@ -83,7 +83,7 @@ PullSecrets define Secrets used to pull Image from registry
8383

8484
### .spec.deployment.project.resources
8585

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

8888
Resources holds resource requests & limits for container
8989

@@ -155,7 +155,7 @@ PullSecrets define Secrets used to pull Image from registry
155155

156156
### .spec.deployment.training.resources
157157

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

160160
Resources holds resource requests & limits for container
161161

@@ -172,6 +172,48 @@ Image define image details
172172

173173
***
174174

175+
### .spec.init.affinity
176+
177+
Type: `core.Affinity` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L37)</sup>
178+
179+
Affinity defines scheduling constraints for workload
180+
181+
Links:
182+
* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity)
183+
184+
***
185+
186+
### .spec.init.hostIPC
187+
188+
Type: `boolean` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L33)</sup>
189+
190+
HostIPC defines to use the host's ipc namespace.
191+
192+
Default Value: `false`
193+
194+
***
195+
196+
### .spec.init.hostNetwork
197+
198+
Type: `boolean` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L27)</sup>
199+
200+
HostNetwork requests Host network for this pod. Use the host's network namespace.
201+
If this option is set, the ports that will be used must be specified.
202+
203+
Default Value: `false`
204+
205+
***
206+
207+
### .spec.init.hostPID
208+
209+
Type: `boolean` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L30)</sup>
210+
211+
HostPID define to use the host's pid namespace.
212+
213+
Default Value: `false`
214+
215+
***
216+
175217
### .spec.init.image
176218

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

181223
***
182224

225+
### .spec.init.nodeSelector
226+
227+
Type: `object` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L32)</sup>
228+
229+
NodeSelector is a selector that must be true for the workload to fit on a node.
230+
231+
Links:
232+
* [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector)
233+
234+
***
235+
236+
### .spec.init.podSecurityContext
237+
238+
Type: `core.PodSecurityContext` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_pod.go#L29)</sup>
239+
240+
PodSecurityContext holds pod-level security attributes and common container settings.
241+
242+
Links:
243+
* [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)
244+
245+
***
246+
183247
### .spec.init.pullPolicy
184248

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

199263
***
200264

265+
### .spec.init.resources
266+
267+
Type: `core.ResourceRequirements` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/resources.go#L34)</sup>
268+
269+
Resources holds resource requests & limits for container
270+
271+
Links:
272+
* [Documentation of core.ResourceRequirements](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/#resourcerequirements-v1-core)
273+
274+
***
275+
276+
### .spec.init.schedulerName
277+
278+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L47)</sup>
279+
280+
SchedulerName specifies, the pod will be dispatched by specified scheduler.
281+
If not specified, the pod will be dispatched by default scheduler.
282+
283+
Default Value: `""`
284+
285+
***
286+
287+
### .spec.init.securityContext
288+
289+
Type: `core.SecurityContext` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_container.go#L29)</sup>
290+
291+
PodSecurityContext holds pod-level security attributes and common container settings.
292+
293+
Links:
294+
* [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)
295+
296+
***
297+
298+
### .spec.init.shareProcessNamespace
299+
300+
Type: `boolean` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/container_namespace.go#L39)</sup>
301+
302+
ShareProcessNamespace defines to share a single process namespace between all of the containers in a pod.
303+
When this is set containers will be able to view and signal processes from other containers
304+
in the same pod, and the first process in each container will not be assigned PID 1.
305+
HostPID and ShareProcessNamespace cannot both be set.
306+
307+
Default Value: `false`
308+
309+
***
310+
311+
### .spec.init.tolerations
312+
313+
Type: `[]core.Toleration` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/scheduling.go#L42)</sup>
314+
315+
Tolerations defines tolerations
316+
317+
Links:
318+
* [Kubernetes docs](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)
319+
320+
***
321+
201322
### .spec.metadataService.local.arangoMLFeatureStore
202323

203324
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>

docs/api/ArangoMLStorage.V1Alpha1.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ PullSecrets define Secrets used to pull Image from registry
136136

137137
### .spec.mode.sidecar.resources
138138

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

141141
Resources holds resource requests & limits for container
142142

@@ -145,6 +145,17 @@ Links:
145145

146146
***
147147

148+
### .spec.mode.sidecar.securityContext
149+
150+
Type: `core.SecurityContext` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/security_container.go#L29)</sup>
151+
152+
PodSecurityContext holds pod-level security attributes and common container settings.
153+
154+
Links:
155+
* [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)
156+
157+
***
158+
148159
### .spec.mode.sidecar.shutdownListenPort
149160

150161
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>

pkg/apis/ml/v1alpha1/extension_spec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (a *ArangoMLExtensionSpec) Validate() error {
9292
shared.PrefixResourceErrors("storage", shared.ValidateRequired(a.GetStorage(), func(obj sharedApi.Object) error { return obj.Validate() })),
9393
a.GetImage().Validate(),
9494
shared.PrefixResourceErrors("init", a.GetInit().Validate()),
95-
shared.ValidateAnyNotNil(".image or .init.image needs to be specified", a.GetImage(), a.GetInit().GetImage()),
95+
shared.ValidateAnyNotNil(".image or .init.image needs to be specified", a.GetImage(), a.GetInit().GetContainerTemplate().GetImage()),
9696
shared.PrefixResourceErrors("deployment", a.GetDeployment().Validate()),
9797
))
9898
}

pkg/apis/ml/v1alpha1/extension_spec_init.go renamed to pkg/apis/ml/v1alpha1/extension_spec_init_job.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,36 @@ import (
2626
)
2727

2828
type ArangoMLExtensionSpecInit struct {
29-
// Image define default image used for the init job
30-
*sharedApi.Image `json:",inline"`
29+
// PodTemplate keeps the information about Pod configuration
30+
*sharedApi.PodTemplate `json:",inline"`
31+
32+
// ContainerTemplate Keeps the information about Container configuration
33+
*sharedApi.ContainerTemplate `json:",inline"`
3134
}
3235

33-
func (a *ArangoMLExtensionSpecInit) GetImage() *sharedApi.Image {
34-
if a == nil || a.Image == nil {
36+
func (a *ArangoMLExtensionSpecInit) GetPodTemplate() *sharedApi.PodTemplate {
37+
if a == nil {
3538
return nil
3639
}
3740

38-
return a.Image
41+
return a.PodTemplate
42+
}
43+
44+
func (a *ArangoMLExtensionSpecInit) GetContainerTemplate() *sharedApi.ContainerTemplate {
45+
if a == nil {
46+
return nil
47+
}
48+
49+
return a.ContainerTemplate
3950
}
4051

4152
func (a *ArangoMLExtensionSpecInit) Validate() error {
4253
if a == nil {
4354
return nil
4455
}
56+
4557
return shared.WithErrors(
46-
a.GetImage().Validate(),
58+
a.GetPodTemplate().Validate(),
59+
a.GetContainerTemplate().Validate(),
4760
)
4861
}

pkg/apis/ml/v1alpha1/storage_spec_mode_sidecar.go

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,16 @@ type ArangoMLStorageSpecModeSidecar struct {
3535
// +doc/default: 9202
3636
ShutdownListenPort *uint16 `json:"shutdownListenPort,omitempty"`
3737

38-
// Image define default image used for the extension
39-
*sharedApi.Image `json:",inline"`
40-
41-
// Resources holds resource requests & limits for sidecar container
42-
*sharedApi.Resources `json:",inline"`
43-
}
44-
45-
func (s *ArangoMLStorageSpecModeSidecar) GetImage() *sharedApi.Image {
46-
if s == nil || s.Image == nil {
47-
return nil
48-
}
49-
50-
return s.Image
38+
// ContainerTemplate Keeps the information about Container configuration
39+
*sharedApi.ContainerTemplate `json:",inline"`
5140
}
5241

53-
func (s *ArangoMLStorageSpecModeSidecar) GetResources() *sharedApi.Resources {
54-
if s == nil || s.Resources == nil {
42+
func (s *ArangoMLStorageSpecModeSidecar) GetContainerTemplate() *sharedApi.ContainerTemplate {
43+
if s == nil || s.ContainerTemplate == nil {
5544
return nil
5645
}
5746

58-
return s.Resources
47+
return s.ContainerTemplate
5948
}
6049

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

76-
err = append(err, s.GetResources().Validate())
65+
err = append(err, s.GetContainerTemplate().Validate())
7766

7867
return shared.WithErrors(err...)
7968
}

pkg/apis/ml/v1alpha1/storage_spec_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func Test_ArangoMLStorageSpec(t *testing.T) {
6666
core.ResourceMemory: resource.MustParse("128Mi"),
6767
},
6868
}
69+
s.Mode.Sidecar.ContainerTemplate = &sharedApi.ContainerTemplate{}
6970
s.Mode.Sidecar.Resources = &sharedApi.Resources{Resources: &assignedRequirements}
7071

7172
expectedRequirements := core.ResourceRequirements{
@@ -76,7 +77,7 @@ func Test_ArangoMLStorageSpec(t *testing.T) {
7677
},
7778
}
7879

79-
actualRequirements := s.Mode.Sidecar.GetResources().With(core.ResourceRequirements{
80+
actualRequirements := s.Mode.Sidecar.GetResources().With(&sharedApi.Resources{Resources: &core.ResourceRequirements{
8081
Limits: core.ResourceList{
8182
core.ResourceCPU: resource.MustParse("100m"),
8283
core.ResourceMemory: resource.MustParse("128Mi"),
@@ -85,7 +86,7 @@ func Test_ArangoMLStorageSpec(t *testing.T) {
8586
core.ResourceCPU: resource.MustParse("200m"),
8687
core.ResourceMemory: resource.MustParse("256Mi"),
8788
},
88-
})
89-
require.Equal(t, expectedRequirements, actualRequirements)
89+
}})
90+
require.Equal(t, expectedRequirements, *actualRequirements.GetResources())
9091
})
9192
}

pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)