Skip to content

Commit f01fcd2

Browse files
committed
[Feature] Add Default Container Mods
1 parent e1befd0 commit f01fcd2

7 files changed

+729
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
44
- (Maintenance) Extend Documentation
5+
- (Feature) Add Default Container Mods
56

67
## [1.2.47](https://github.com/arangodb/kube-arangodb/tree/1.2.47) (2025-03-28)
78
- (Bugfix) Use Profile Annotations

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ init: vendor tools update-generated $(BIN)
794794
.PHONY: tools-min
795795
tools-min: update-vendor
796796
@echo ">> Fetching golangci-lint linter"
797-
@GOBIN=$(GOPATH)/bin go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.63.4
797+
@GOBIN=$(GOPATH)/bin go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8
798798
@echo ">> Fetching goimports"
799799
@GOBIN=$(GOPATH)/bin go install golang.org/x/tools/cmd/[email protected]
800800
@echo ">> Fetching license check"

docs/api/ArangoProfile.V1Beta1.md

+184
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,190 @@ might be configured in the container image.
230230

231231
***
232232

233+
### .spec.template.container.default.args
234+
235+
Type: `array` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/scheduler/v1beta1/container/resources/core.go#L54)</sup>
236+
237+
Arguments to the entrypoint.
238+
The container image's CMD is used if this is not provided.
239+
Variable references $(VAR_NAME) are expanded using the container's environment. If a variable
240+
cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced
241+
to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will
242+
produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless
243+
of whether the variable exists or not. Cannot be updated.
244+
245+
Links:
246+
* [Kubernetes Docs](https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell)
247+
248+
***
249+
250+
### .spec.template.container.default.command
251+
252+
Type: `array` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/scheduler/v1beta1/container/resources/core.go#L44)</sup>
253+
254+
Entrypoint array. Not executed within a shell.
255+
The container image's ENTRYPOINT is used if this is not provided.
256+
Variable references $(VAR_NAME) are expanded using the container's environment. If a variable
257+
cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced
258+
to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will
259+
produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless
260+
of whether the variable exists or not. Cannot be updated.
261+
262+
Links:
263+
* [Kubernetes Docs](https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell)
264+
265+
***
266+
267+
### .spec.template.container.default.env
268+
269+
Type: `core.EnvVar` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/scheduler/v1beta1/container/resources/environments.go#L36)</sup>
270+
271+
Env keeps the information about environment variables provided to the container
272+
273+
Links:
274+
* [Kubernetes Docs](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#envvar-v1-core)
275+
276+
***
277+
278+
### .spec.template.container.default.envFrom
279+
280+
Type: `core.EnvFromSource` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/scheduler/v1beta1/container/resources/environments.go#L41)</sup>
281+
282+
EnvFrom keeps the information about environment variable sources provided to the container
283+
284+
Links:
285+
* [Kubernetes Docs](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#envfromsource-v1-core)
286+
287+
***
288+
289+
### .spec.template.container.default.image
290+
291+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/scheduler/v1beta1/container/resources/image.go#L35)</sup>
292+
293+
Image define image details
294+
295+
***
296+
297+
### .spec.template.container.default.imagePullPolicy
298+
299+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/scheduler/v1beta1/container/resources/image.go#L39)</sup>
300+
301+
ImagePullPolicy define Image pull policy
302+
303+
Default Value: `IfNotPresent`
304+
305+
***
306+
307+
### .spec.template.container.default.lifecycle
308+
309+
Type: `core.Lifecycle` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/scheduler/v1beta1/container/resources/lifecycle.go#L35)</sup>
310+
311+
Lifecycle keeps actions that the management system should take in response to container lifecycle events.
312+
313+
***
314+
315+
### .spec.template.container.default.livenessProbe
316+
317+
Type: `core.Probe` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/scheduler/v1beta1/container/resources/probes.go#L37)</sup>
318+
319+
LivenessProbe keeps configuration of periodic probe of container liveness.
320+
Container will be restarted if the probe fails.
321+
322+
Links:
323+
* [Kubernetes docs](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes)
324+
325+
***
326+
327+
### .spec.template.container.default.method
328+
329+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/scheduler/v1beta1/policy/merge.go#L32)</sup>
330+
331+
Method defines the merge method
332+
333+
Possible Values:
334+
* `"override"` (default) - Overrides values during configuration merge
335+
* `"append"` - Appends, if possible, values during configuration merge
336+
337+
***
338+
339+
### .spec.template.container.default.ports
340+
341+
Type: `[]core.ContainerPort` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/scheduler/v1beta1/container/resources/networking.go#L39)</sup>
342+
343+
Ports contains list of ports to expose from the container. Not specifying a port here
344+
DOES NOT prevent that port from being exposed. Any port which is
345+
listening on the default "0.0.0.0" address inside a container will be
346+
accessible from the network.
347+
348+
***
349+
350+
### .spec.template.container.default.readinessProbe
351+
352+
Type: `core.Probe` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/scheduler/v1beta1/container/resources/probes.go#L42)</sup>
353+
354+
ReadinessProbe keeps configuration of periodic probe of container service readiness.
355+
Container will be removed from service endpoints if the probe fails.
356+
357+
Links:
358+
* [Kubernetes docs](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes)
359+
360+
***
361+
362+
### .spec.template.container.default.resources
363+
364+
Type: `core.ResourceRequirements` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/scheduler/v1beta1/container/resources/resources.go#L37)</sup>
365+
366+
Resources holds resource requests & limits for container
367+
368+
Links:
369+
* [Documentation of core.ResourceRequirements](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#resourcerequirements-v1-core)
370+
371+
***
372+
373+
### .spec.template.container.default.securityContext
374+
375+
Type: `core.SecurityContext` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/scheduler/v1beta1/container/resources/security.go#L35)</sup>
376+
377+
SecurityContext holds container-level security attributes and common container settings.
378+
379+
Links:
380+
* [Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)
381+
382+
***
383+
384+
### .spec.template.container.default.startupProbe
385+
386+
Type: `core.Probe` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/scheduler/v1beta1/container/resources/probes.go#L50)</sup>
387+
388+
StartupProbe indicates that the Pod has successfully initialized.
389+
If specified, no other probes are executed until this completes successfully.
390+
If this probe fails, the Pod will be restarted, just as if the livenessProbe failed.
391+
This can be used to provide different probe parameters at the beginning of a Pod's lifecycle,
392+
when it might take a long time to load data or warm a cache, than during steady-state operation.
393+
394+
Links:
395+
* [Kubernetes docs](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes)
396+
397+
***
398+
399+
### .spec.template.container.default.volumeMounts
400+
401+
Type: `[]core.VolumeMount` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/scheduler/v1beta1/container/resources/volume_mounts.go#L35)</sup>
402+
403+
VolumeMounts keeps list of pod volumes to mount into the container's filesystem.
404+
405+
***
406+
407+
### .spec.template.container.default.workingDir
408+
409+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/scheduler/v1beta1/container/resources/core.go#L59)</sup>
410+
411+
Container's working directory.
412+
If not specified, the container runtime's default will be used, which
413+
might be configured in the container image.
414+
415+
***
416+
233417
### .spec.template.pod.affinity
234418

235419
Type: `core.Affinity` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/scheduler/v1beta1/pod/resources/scheduling.go#L44)</sup>

pkg/apis/scheduler/v1beta1/profile_container_template.go

+32-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2024-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ import (
2525

2626
schedulerContainerApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1/container"
2727
shared "github.com/arangodb/kube-arangodb/pkg/apis/shared"
28+
"github.com/arangodb/kube-arangodb/pkg/util/errors"
2829
)
2930

3031
type ProfileContainerTemplate struct {
@@ -33,6 +34,9 @@ type ProfileContainerTemplate struct {
3334

3435
// All applies generic values to all Containers
3536
All *schedulerContainerApi.Generic `json:"all,omitempty"`
37+
38+
// Default applies generic values to default Container (first one on the list)
39+
Default *schedulerContainerApi.Container `json:"default,omitempty"`
3640
}
3741

3842
func (p *ProfileContainerTemplate) ApplyContainers(template *core.PodTemplateSpec) error {
@@ -51,6 +55,32 @@ func (p *ProfileContainerTemplate) ApplyGeneric(template *core.PodTemplateSpec)
5155
return p.All.Apply(template)
5256
}
5357

58+
func (p *ProfileContainerTemplate) ApplyDefault(template *core.PodTemplateSpec) error {
59+
if p == nil {
60+
return nil
61+
}
62+
63+
if template == nil {
64+
return errors.Errorf("Template is nil")
65+
}
66+
67+
if len(template.Spec.Containers) == 0 {
68+
return errors.Errorf("Default container is missing")
69+
}
70+
71+
var cont core.Container
72+
73+
template.Spec.Containers[0].DeepCopyInto(&cont)
74+
75+
if err := p.Default.Apply(template, &cont); err != nil {
76+
return err
77+
}
78+
79+
template.Spec.Containers[0] = cont
80+
81+
return nil
82+
}
83+
5484
func (p *ProfileContainerTemplate) With(other *ProfileContainerTemplate) *ProfileContainerTemplate {
5585
if p == nil && other == nil {
5686
return nil
@@ -67,6 +97,7 @@ func (p *ProfileContainerTemplate) With(other *ProfileContainerTemplate) *Profil
6797
return &ProfileContainerTemplate{
6898
Containers: p.Containers.With(other.Containers),
6999
All: p.All.With(other.All),
100+
Default: p.Default.With(other.Default),
70101
}
71102
}
72103

pkg/apis/scheduler/v1beta1/profile_templates.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2024-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -65,6 +65,11 @@ func (p ProfileTemplates) RenderOnTemplate(pod *core.PodTemplateSpec) error {
6565
return errors.Wrapf(err, "Error while rendering ArangoSchedulerPod")
6666
}
6767

68+
// Apply Default Containers Spec
69+
if err := t.GetContainer().ApplyDefault(pod); err != nil {
70+
return errors.Wrapf(err, "Error while rendering ArangoSchedulerPod")
71+
}
72+
6873
// Apply Containers Spec
6974
if err := t.GetContainer().ApplyContainers(pod); err != nil {
7075
return errors.Wrapf(err, "Error while rendering ArangoSchedulerPod")

pkg/apis/scheduler/v1beta1/zz_generated.deepcopy.go

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)