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] Pass Arguments to ID Group #1551

Merged
merged 1 commit into from
Dec 27, 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 @@ -39,6 +39,7 @@
- (Feature) (ML) Support for deployments with JWT auth enabled
- (Feature) (ML) GPU Jobs
- (Feature) (ML) Container Envs
- (Feature) Pass Arguments to ID Group

## [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
26 changes: 18 additions & 8 deletions docs/api/ArangoDeployment.V1.md
Original file line number Diff line number Diff line change
Expand Up @@ -2979,7 +2979,7 @@ Type: `boolean` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.

### .spec.id.affinity

Type: `core.PodAffinity` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/deployment/v1/server_id_group_spec.go#L44)</sup>
Type: `core.PodAffinity` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/deployment/v1/server_id_group_spec.go#L48)</sup>

Affinity specified additional affinity settings in ArangoDB Pod definitions

Expand All @@ -2990,7 +2990,7 @@ Links:

### .spec.id.antiAffinity

Type: `core.PodAntiAffinity` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/deployment/v1/server_id_group_spec.go#L40)</sup>
Type: `core.PodAntiAffinity` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/deployment/v1/server_id_group_spec.go#L44)</sup>

AntiAffinity specified additional antiAffinity settings in ArangoDB Pod definitions

Expand All @@ -2999,6 +2999,16 @@ Links:

***

### .spec.id.args

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

Args setting specifies additional command-line arguments passed to all servers of this group.

Default Value: `[]`

***

### .spec.id.entrypoint

Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/deployment/v1/server_id_group_spec.go#L28)</sup>
Expand All @@ -3009,7 +3019,7 @@ Entrypoint overrides container executable

### .spec.id.nodeAffinity

Type: `core.NodeAffinity` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/deployment/v1/server_id_group_spec.go#L48)</sup>
Type: `core.NodeAffinity` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/deployment/v1/server_id_group_spec.go#L52)</sup>

NodeAffinity specified additional nodeAffinity settings in ArangoDB Pod definitions

Expand All @@ -3020,23 +3030,23 @@ Links:

### .spec.id.nodeSelector

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

NodeSelector specifies a set of selectors for nodes

***

### .spec.id.priorityClassName

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

PriorityClassName specifies a priority class name

***

### .spec.id.resources

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

Resources holds resource requests & limits

Expand Down Expand Up @@ -3173,15 +3183,15 @@ sysctls:

### .spec.id.serviceAccountName

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

ServiceAccountName specifies the name of the service account used for Pods in this group.

***

### .spec.id.tolerations

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

Tolerations specifies the tolerations added to Pods in this group.

Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/deployment/v1/server_id_group_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import core "k8s.io/api/core/v1"
type ServerIDGroupSpec struct {
// Entrypoint overrides container executable
Entrypoint *string `json:"entrypoint,omitempty"`
// Args setting specifies additional command-line arguments passed to all servers of this group.
// +doc/type: []string
// +doc/default: []
Args []string `json:"args,omitempty"`
// Tolerations specifies the tolerations added to Pods in this group.
// +doc/type: []core.Toleration
// +doc/link: Documentation of core.Toleration|https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/#toleration-v1-core
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/deployment/v1/zz_generated.deepcopy.go

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

4 changes: 4 additions & 0 deletions pkg/apis/deployment/v2alpha1/server_id_group_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import core "k8s.io/api/core/v1"
type ServerIDGroupSpec struct {
// Entrypoint overrides container executable
Entrypoint *string `json:"entrypoint,omitempty"`
// Args setting specifies additional command-line arguments passed to all servers of this group.
// +doc/type: []string
// +doc/default: []
Args []string `json:"args,omitempty"`
// Tolerations specifies the tolerations added to Pods in this group.
// +doc/type: []core.Toleration
// +doc/link: Documentation of core.Toleration|https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/#toleration-v1-core
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/deployment/v2alpha1/zz_generated.deepcopy.go

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

15 changes: 15 additions & 0 deletions pkg/crd/crds/database-deployment.schema.generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6461,6 +6461,11 @@ v1:
type: object
type: array
type: object
args:
description: Args setting specifies additional command-line arguments passed to all servers of this group.
items:
type: string
type: array
entrypoint:
description: Entrypoint overrides container executable
type: string
Expand Down Expand Up @@ -19620,6 +19625,11 @@ v1alpha:
type: object
type: array
type: object
args:
description: Args setting specifies additional command-line arguments passed to all servers of this group.
items:
type: string
type: array
entrypoint:
description: Entrypoint overrides container executable
type: string
Expand Down Expand Up @@ -32779,6 +32789,11 @@ v2alpha1:
type: object
type: array
type: object
args:
description: Args setting specifies additional command-line arguments passed to all servers of this group.
items:
type: string
type: array
entrypoint:
description: Entrypoint overrides container executable
type: string
Expand Down
9 changes: 8 additions & 1 deletion pkg/deployment/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ type ContainerIdentity struct {
type ArangoDIdentity struct {
interfaces.ContainerCreator
input pod.Input
ID *api.ServerIDGroupSpec
License *string
ipAddress string
}
Expand Down Expand Up @@ -238,6 +239,7 @@ func (ib *imagesBuilder) fetchArangoDBImageIDAndVersion(ctx context.Context, cac
image: image,
imagePullPolicy: ib.Spec.GetImagePullPolicy(),
},
ID: ib.Spec.ID,
License: license,
ipAddress: ib.Spec.GetListenAddr(),
},
Expand Down Expand Up @@ -460,7 +462,12 @@ func (a *ArangoDIdentity) GetCommand() ([]string, error) {
// Security
options.Merge(pod.Security().Args(a.input))

return options.Copy().Sort().AsArgsWithCommand(a.GetExecutor()), nil
args := options.Copy().Sort().AsArgsWithCommand(a.GetExecutor())
if added := a.ID.Get().Args; len(added) > 0 {
args = append(args, added...)
}

return args, nil
}

// GetEnvs returns environment variables for Arango identity containers.
Expand Down
46 changes: 46 additions & 0 deletions pkg/deployment/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,52 @@ func TestEnsureImages(t *testing.T) {
},
},
},
{
Name: "Image has been changed with custom args",
ArangoDeployment: &api.ArangoDeployment{
Spec: api.DeploymentSpec{
Image: util.NewType[string](testNewImage),

ID: &api.ServerIDGroupSpec{
Args: []string{
"--my-custom-arg",
},
},
},
},
RetrySoon: true,
ExpectedPod: core.Pod{
Spec: core.PodSpec{
Volumes: []core.Volume{
k8sutil.CreateVolumeEmptyDir(shared.ArangodVolumeName),
},
Containers: []core.Container{
{
Name: shared.ServerContainerName,
Image: testNewImage,
Command: append(createTestCommandForImageUpdatePod(), "--my-custom-arg"),
Ports: createTestPorts(api.ServerGroupAgents),
Resources: core.ResourceRequirements{
Limits: make(core.ResourceList),
Requests: make(core.ResourceList),
},
VolumeMounts: []core.VolumeMount{
k8sutil.ArangodVolumeMount(),
},
ImagePullPolicy: core.PullIfNotPresent,
SecurityContext: securityContext.NewSecurityContext(),
},
},
RestartPolicy: core.RestartPolicyNever,
Tolerations: getTestTolerations(),
TerminationGracePeriodSeconds: &terminationGracePeriodSeconds,
Hostname: hostname,
Subdomain: testDeploymentName + "-int",
Affinity: k8sutil.CreateAffinity(testDeploymentName,
api.ServerGroupImageDiscovery.AsRole(), false, ""),
},
},
},
{
Before: func(t *testing.T, deployment *Deployment) {
c := deployment.acs.CurrentClusterCache()
Expand Down