diff --git a/Makefile b/Makefile index fbab99a05c..d1280296eb 100644 --- a/Makefile +++ b/Makefile @@ -12,10 +12,10 @@ TIME ?= time -p ARCH ?= $(shell uname -m) VERSION ?= $(shell go run cmd/version/main.go) -IMAGE ?= noobaa/noobaa-operator:$(VERSION) +IMAGE ?= nooverflow/noobaa-operator:$(VERSION) DEV_IMAGE ?= noobaa/noobaa-operator-dev:$(VERSION) REPO ?= github.com/noobaa/noobaa-operator -CATALOG_IMAGE ?= noobaa/noobaa-operator-catalog:$(VERSION) +CATALOG_IMAGE ?= nooverflow/noobaa-operator-catalog:$(VERSION) BUNDLE_IMAGE ?= noobaa/noobaa-operator-bundle:$(VERSION) # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) ifeq (,$(shell go env GOBIN)) @@ -279,7 +279,7 @@ test-util: vendor @echo "✅ test-util" .PHONY: test-util -test-validations: +test-validations: ginkgo -v pkg/validations @echo "✅ test-validations" .PHONY: test-validations diff --git a/deploy/crds/noobaa.io_noobaas.yaml b/deploy/crds/noobaa.io_noobaas.yaml index 639a844541..710757aaaa 100644 --- a/deploy/crds/noobaa.io_noobaas.yaml +++ b/deploy/crds/noobaa.io_noobaas.yaml @@ -1573,6 +1573,26 @@ spec: type: object type: object type: object + envVariablesOverride: + 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 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 + type: object + x-kubernetes-preserve-unknown-fields: true + type: array externalPgSSLRequired: description: ExternalPgSSLRequired (optional) holds an optional boolean to force ssl connections to the external Postgres DB diff --git a/pkg/apis/noobaa/v1alpha1/noobaa_types.go b/pkg/apis/noobaa/v1alpha1/noobaa_types.go index 829621dda7..291c9c3c39 100644 --- a/pkg/apis/noobaa/v1alpha1/noobaa_types.go +++ b/pkg/apis/noobaa/v1alpha1/noobaa_types.go @@ -91,6 +91,11 @@ type NooBaaSpec struct { // +kubebuilder:validation:Enum=postgres DBType DBTypes `json:"dbType,omitempty"` + // EnvVariablesOverride (optional) overrides the environment variables for all NooBaa's pods + // Can be used for exemple to add CONFIG_JS_ variables to modify core pod behaviour + // +optional + EnvVariablesOverride *EnvVariablesOverrideSpec `json:"envVariablesOverride,omitempty"` + // CoreResources (optional) overrides the default resource requirements for the server container // +optional CoreResources *corev1.ResourceRequirements `json:"coreResources,omitempty"` @@ -245,6 +250,17 @@ type AutoscalerSpec struct { PrometheusNamespace string `json:"prometheusNamespace,omitempty"` } +// EnvVariablesOverrideSpec defines the env override structure for each component deploying pods (ex: StatefulSet) +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"` +} + + + // BucketLoggingSpec defines the bucket logging configuration type BucketLoggingSpec struct { // LoggingType specifies the type of logging for the bucket diff --git a/pkg/bundle/deploy.go b/pkg/bundle/deploy.go index 1b95f6a199..3104a7dd18 100644 --- a/pkg/bundle/deploy.go +++ b/pkg/bundle/deploy.go @@ -1423,7 +1423,7 @@ spec: status: {} ` -const Sha256_deploy_crds_noobaa_io_noobaas_yaml = "e862d263d097ed43f774784eaaf9a616967746b67608fadbe4ca71d93b220ab6" +const Sha256_deploy_crds_noobaa_io_noobaas_yaml = "db1c4c18af61b965669cff3e76227bbcbd8519ea9a9fdd41ad39fdc318806110" const File_deploy_crds_noobaa_io_noobaas_yaml = `--- apiVersion: apiextensions.k8s.io/v1 @@ -3000,6 +3000,26 @@ spec: type: object type: object type: object + envVariablesOverride: + 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 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 + type: object + x-kubernetes-preserve-unknown-fields: true + type: array externalPgSSLRequired: description: ExternalPgSSLRequired (optional) holds an optional boolean to force ssl connections to the external Postgres DB diff --git a/pkg/options/options.go b/pkg/options/options.go index ebb9e46b12..a46d35ab57 100644 --- a/pkg/options/options.go +++ b/pkg/options/options.go @@ -61,7 +61,7 @@ var Namespace = "noobaa" // OperatorImage is the container image url built from https://github.com/noobaa/noobaa-operator // it can be overridden for testing or different registry locations. -var OperatorImage = "noobaa/noobaa-operator:" + version.Version +var OperatorImage = "nooverflow/noobaa-operator:" + version.Version // CosiSideCarImage is the container image url built from https://github.com/kubernetes-sigs/container-object-storage-interface-provisioner-sidecar var CosiSideCarImage = "gcr.io/k8s-staging-sig-storage/objectstorage-sidecar/objectstorage-sidecar:v20221117-v0.1.0-22-g0e67387" diff --git a/pkg/system/phase2_creating.go b/pkg/system/phase2_creating.go index 5a882a3cd2..968457214e 100644 --- a/pkg/system/phase2_creating.go +++ b/pkg/system/phase2_creating.go @@ -477,7 +477,6 @@ func (r *Reconciler) setDesiredCoreEnv(c *corev1.Container) { } util.MergeEnvArrays(&c.Env, &[]corev1.EnvVar{envVar}); } - } // SetDesiredCoreApp updates the CoreApp as desired for reconciling @@ -616,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 = diff --git a/pkg/system/phase4_configuring.go b/pkg/system/phase4_configuring.go index 87062c6c9c..2192ee4296 100644 --- a/pkg/system/phase4_configuring.go +++ b/pkg/system/phase4_configuring.go @@ -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) } }