Skip to content

Commit

Permalink
Add EnvVariablesOverride field for endpoint deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
NoOverflow committed Jan 19, 2025
1 parent b4ad545 commit 5e03e1e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 13 deletions.
12 changes: 10 additions & 2 deletions deploy/crds/noobaa.io_noobaas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1644,11 +1644,19 @@ spec:
type: object
type: object
envVariablesOverride:
description: "huh"
description: Override variables for all pods managed by NooBaa's operator
type: object
properties:
core:
description: "List of environment variables to set in the Core statefulset container. Cannot be updated."
description: "List of environment variables to set in the Core statefulset containers."
items:
description: EnvVar represents an environment variable present in a Container.
x-kubernetes-preserve-unknown-fields: true
type: object
x-kubernetes-preserve-unknown-fields: true
type: array
endpoint:
description: "List of environment variables to set in the Endpoint deployment containers."
items:
description: EnvVar represents an environment variable present in a Container.
x-kubernetes-preserve-unknown-fields: true
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/noobaa/v1alpha1/noobaa_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ type AutoscalerSpec struct {
type EnvVariablesOverrideSpec struct {
// Variables override for core statefulset
Core []corev1.EnvVar `json:"core,omitempty"`

// Variables override for endpoint deployment
Endpoint []corev1.EnvVar `json:"endpoint,omitempty"`
}


Expand Down
14 changes: 11 additions & 3 deletions pkg/bundle/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ spec:
status: {}
`

const Sha256_deploy_crds_noobaa_io_noobaas_yaml = "c354dda7e40756f33fe9daf07a240e92b55ac9c537bdf51101e8fe0f47cefc7e"
const Sha256_deploy_crds_noobaa_io_noobaas_yaml = "d159d72a783f65f4c9ff716fc2c2c7ba4983c36d73ad3ca3b29c87cfe3707767"

const File_deploy_crds_noobaa_io_noobaas_yaml = `---
apiVersion: apiextensions.k8s.io/v1
Expand Down Expand Up @@ -3071,11 +3071,19 @@ spec:
type: object
type: object
envVariablesOverride:
description: "huh"
description: Override variables for all pods managed by NooBaa's operator
type: object
properties:
core:
description: "List of environment variables to set in the Core statefulset container. Cannot be updated."
description: "List of environment variables to set in the Core statefulset containers."
items:
description: EnvVar represents an environment variable present in a Container.
x-kubernetes-preserve-unknown-fields: true
type: object
x-kubernetes-preserve-unknown-fields: true
type: array
endpoint:
description: "List of environment variables to set in the Endpoint deployment containers."
items:
description: EnvVar represents an environment variable present in a Container.
x-kubernetes-preserve-unknown-fields: true
Expand Down
16 changes: 8 additions & 8 deletions pkg/system/phase2_creating.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,14 +477,6 @@ func (r *Reconciler) setDesiredCoreEnv(c *corev1.Container) {
}
util.MergeEnvArrays(&c.Env, &[]corev1.EnvVar{envVar});
}

if r.NooBaa.Spec.EnvVariablesOverride != nil && r.NooBaa.Spec.EnvVariablesOverride.Core != nil {
// util.MergeEnvArrays will keep variables of the first array provided in
// arguments in case of a conflict, so we provide the override array first
// and then set the container Env array to the resulting merged array
util.MergeEnvArrays(&r.NooBaa.Spec.EnvVariablesOverride.Core, &c.Env);
c.Env = r.NooBaa.Spec.EnvVariablesOverride.Core;
}
}

// SetDesiredCoreApp updates the CoreApp as desired for reconciling
Expand Down Expand Up @@ -623,6 +615,14 @@ func (r *Reconciler) SetDesiredCoreApp() error {
util.MergeVolumeMountList(&c.VolumeMounts, &configMapVolumeMounts)
}
}

if r.NooBaa.Spec.EnvVariablesOverride != nil && r.NooBaa.Spec.EnvVariablesOverride.Core != nil {
// util.MergeEnvArrays will keep variables of the first array provided in
// arguments in case of a conflict, so we provide the override array first
// and then set the container Env array to the resulting merged array
util.MergeEnvArrays(&r.NooBaa.Spec.EnvVariablesOverride.Core, &c.Env);
c.Env = r.NooBaa.Spec.EnvVariablesOverride.Core;
}
}
if r.NooBaa.Spec.ImagePullSecret == nil {
podSpec.ImagePullSecrets =
Expand Down
7 changes: 7 additions & 0 deletions pkg/system/phase4_configuring.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,13 @@ func (r *Reconciler) SetDesiredDeploymentEndpoint() error {

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

if r.NooBaa.Spec.EnvVariablesOverride != nil && r.NooBaa.Spec.EnvVariablesOverride.Endpoint != nil {
// util.MergeEnvArrays will keep variables of the first array provided in
// arguments in case of a conflict, so we provide the override array first
// and then set the container Env array to the resulting merged array
util.MergeEnvArrays(&r.NooBaa.Spec.EnvVariablesOverride.Endpoint, &c.Env);
c.Env = r.NooBaa.Spec.EnvVariablesOverride.Endpoint;
}
return r.setDesiredEndpointMounts(podSpec, c)
}
}
Expand Down

0 comments on commit 5e03e1e

Please sign in to comment.