Skip to content

Commit ecd320f

Browse files
committed
Add EnvVariablesOverride field for endpoint deployment
Signed-off-by: NoOverflow <[email protected]>
1 parent b0efd9a commit ecd320f

File tree

5 files changed

+39
-13
lines changed

5 files changed

+39
-13
lines changed

deploy/crds/noobaa.io_noobaas.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,11 +1644,19 @@ spec:
16441644
type: object
16451645
type: object
16461646
envVariablesOverride:
1647-
description: "huh"
1647+
description: Override variables for all pods managed by NooBaa's operator
16481648
type: object
16491649
properties:
16501650
core:
1651-
description: "List of environment variables to set in the Core statefulset container. Cannot be updated."
1651+
description: "List of environment variables to set in the Core statefulset containers."
1652+
items:
1653+
description: EnvVar represents an environment variable present in a Container.
1654+
x-kubernetes-preserve-unknown-fields: true
1655+
type: object
1656+
x-kubernetes-preserve-unknown-fields: true
1657+
type: array
1658+
endpoint:
1659+
description: "List of environment variables to set in the Endpoint deployment containers."
16521660
items:
16531661
description: EnvVar represents an environment variable present in a Container.
16541662
x-kubernetes-preserve-unknown-fields: true

pkg/apis/noobaa/v1alpha1/noobaa_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ type AutoscalerSpec struct {
254254
type EnvVariablesOverrideSpec struct {
255255
// Variables override for core statefulset
256256
Core []corev1.EnvVar `json:"core,omitempty"`
257+
258+
// Variables override for endpoint deployment
259+
Endpoint []corev1.EnvVar `json:"endpoint,omitempty"`
257260
}
258261

259262

pkg/bundle/deploy.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ spec:
14231423
status: {}
14241424
`
14251425

1426-
const Sha256_deploy_crds_noobaa_io_noobaas_yaml = "c354dda7e40756f33fe9daf07a240e92b55ac9c537bdf51101e8fe0f47cefc7e"
1426+
const Sha256_deploy_crds_noobaa_io_noobaas_yaml = "d159d72a783f65f4c9ff716fc2c2c7ba4983c36d73ad3ca3b29c87cfe3707767"
14271427

14281428
const File_deploy_crds_noobaa_io_noobaas_yaml = `---
14291429
apiVersion: apiextensions.k8s.io/v1
@@ -3071,11 +3071,19 @@ spec:
30713071
type: object
30723072
type: object
30733073
envVariablesOverride:
3074-
description: "huh"
3074+
description: Override variables for all pods managed by NooBaa's operator
30753075
type: object
30763076
properties:
30773077
core:
3078-
description: "List of environment variables to set in the Core statefulset container. Cannot be updated."
3078+
description: "List of environment variables to set in the Core statefulset containers."
3079+
items:
3080+
description: EnvVar represents an environment variable present in a Container.
3081+
x-kubernetes-preserve-unknown-fields: true
3082+
type: object
3083+
x-kubernetes-preserve-unknown-fields: true
3084+
type: array
3085+
endpoint:
3086+
description: "List of environment variables to set in the Endpoint deployment containers."
30793087
items:
30803088
description: EnvVar represents an environment variable present in a Container.
30813089
x-kubernetes-preserve-unknown-fields: true

pkg/system/phase2_creating.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -477,14 +477,6 @@ func (r *Reconciler) setDesiredCoreEnv(c *corev1.Container) {
477477
}
478478
util.MergeEnvArrays(&c.Env, &[]corev1.EnvVar{envVar});
479479
}
480-
481-
if r.NooBaa.Spec.EnvVariablesOverride != nil && r.NooBaa.Spec.EnvVariablesOverride.Core != nil {
482-
// util.MergeEnvArrays will keep variables of the first array provided in
483-
// arguments in case of a conflict, so we provide the override array first
484-
// and then set the container Env array to the resulting merged array
485-
util.MergeEnvArrays(&r.NooBaa.Spec.EnvVariablesOverride.Core, &c.Env);
486-
c.Env = r.NooBaa.Spec.EnvVariablesOverride.Core;
487-
}
488480
}
489481

490482
// SetDesiredCoreApp updates the CoreApp as desired for reconciling
@@ -623,6 +615,14 @@ func (r *Reconciler) SetDesiredCoreApp() error {
623615
util.MergeVolumeMountList(&c.VolumeMounts, &configMapVolumeMounts)
624616
}
625617
}
618+
619+
if r.NooBaa.Spec.EnvVariablesOverride != nil && r.NooBaa.Spec.EnvVariablesOverride.Core != nil {
620+
// util.MergeEnvArrays will keep variables of the first array provided in
621+
// arguments in case of a conflict, so we provide the override array first
622+
// and then set the container Env array to the resulting merged array
623+
util.MergeEnvArrays(&r.NooBaa.Spec.EnvVariablesOverride.Core, &c.Env);
624+
c.Env = r.NooBaa.Spec.EnvVariablesOverride.Core;
625+
}
626626
}
627627
if r.NooBaa.Spec.ImagePullSecret == nil {
628628
podSpec.ImagePullSecrets =

pkg/system/phase4_configuring.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,13 @@ func (r *Reconciler) SetDesiredDeploymentEndpoint() error {
440440

441441
r.DeploymentEndpoint.Spec.Template.Annotations["noobaa.io/configmap-hash"] = r.CoreAppConfig.Annotations["noobaa.io/configmap-hash"]
442442

443+
if r.NooBaa.Spec.EnvVariablesOverride != nil && r.NooBaa.Spec.EnvVariablesOverride.Endpoint != nil {
444+
// util.MergeEnvArrays will keep variables of the first array provided in
445+
// arguments in case of a conflict, so we provide the override array first
446+
// and then set the container Env array to the resulting merged array
447+
util.MergeEnvArrays(&r.NooBaa.Spec.EnvVariablesOverride.Endpoint, &c.Env);
448+
c.Env = r.NooBaa.Spec.EnvVariablesOverride.Endpoint;
449+
}
443450
return r.setDesiredEndpointMounts(podSpec, c)
444451
}
445452
}

0 commit comments

Comments
 (0)