From e144372a1677bba7cffbe2afcb4a1999290fa08e Mon Sep 17 00:00:00 2001 From: Smaine Kahlouch Date: Fri, 23 Jun 2023 15:56:45 +0200 Subject: [PATCH 1/2] Being able to set environment variables using 'envFrom' --- templates/server-deployment.yaml | 11 +++++++++++ templates/web-deployment.yaml | 11 +++++++++++ values.yaml | 12 ++++++++++++ 3 files changed, 34 insertions(+) diff --git a/templates/server-deployment.yaml b/templates/server-deployment.yaml index 8c23e204..fccea7c8 100644 --- a/templates/server-deployment.yaml +++ b/templates/server-deployment.yaml @@ -121,6 +121,17 @@ spec: {{- if or $.Values.server.additionalEnv $serviceValues.additionalEnv }} {{- toYaml (default $.Values.server.additionalEnv $serviceValues.additionalEnv) | nindent 12 }} {{- end }} + {{- if or $serviceValues.additionalEnvCM $serviceValues.additionalEnvSecret }} + envFrom: + {{- if $serviceValues.additionalEnvCM }} + - configMapRef: + name: {{ $serviceValues.additionalEnvCM }} + {{- end }} + {{- if $serviceValues.additionalEnvSecret }} + - secretRef: + name: {{ $serviceValues.additionalEnvSecret }} + {{- end }} + {{- end }} ports: - name: rpc containerPort: {{ include (printf "temporal.%s.grpcPort" $service) $ }} diff --git a/templates/web-deployment.yaml b/templates/web-deployment.yaml index bfce3bc9..014edc72 100644 --- a/templates/web-deployment.yaml +++ b/templates/web-deployment.yaml @@ -51,6 +51,17 @@ spec: {{- if .Values.web.additionalEnv }} {{- toYaml .Values.web.additionalEnv | nindent 12 }} {{- end }} + {{- if or .Values.web.additionalEnvCM .Values.web.additionalEnvSecret }} + envFrom: + {{- if .Values.web.additionalEnvCM }} + - configMapRef: + name: {{ .Values.web.additionalEnvCM }} + {{- end }} + {{- if .Values.web.additionalEnvSecret }} + - secretRef: + name: {{ .Values.web.additionalEnvSecret }} + {{- end }} + {{- end }} ports: - name: http containerPort: 8080 diff --git a/values.yaml b/values.yaml index 3c28805d..a5481712 100644 --- a/values.yaml +++ b/values.yaml @@ -84,6 +84,8 @@ server: additionalVolumes: [] additionalVolumeMounts: [] additionalEnv: [] + additionalEnvCM: "" + additionalEnvSecret: "" securityContext: fsGroup: 1000 runAsUser: 1000 @@ -183,6 +185,8 @@ server: tolerations: [] affinity: {} additionalEnv: [] + additionalEnvCM: "" + additionalEnvSecret: "" containerSecurityContext: {} topologySpreadConstraints: {} podDisruptionBudget: {} @@ -205,6 +209,8 @@ server: tolerations: [] affinity: {} additionalEnv: [] + additionalEnvCM: "" + additionalEnvSecret: "" containerSecurityContext: {} topologySpreadConstraints: {} podDisruptionBudget: {} @@ -227,6 +233,8 @@ server: tolerations: [] affinity: {} additionalEnv: [] + additionalEnvCM: "" + additionalEnvSecret: "" containerSecurityContext: {} topologySpreadConstraints: {} podDisruptionBudget: {} @@ -249,6 +257,8 @@ server: tolerations: [] affinity: {} additionalEnv: [] + additionalEnvCM: "" + additionalEnvSecret: "" containerSecurityContext: {} topologySpreadConstraints: {} podDisruptionBudget: {} @@ -270,6 +280,8 @@ admintools: tolerations: [] affinity: {} additionalEnv: [] + additionalEnvCM: "" + additionalEnvSecret: "" resources: {} containerSecurityContext: {} securityContext: {} From 2fb237b6c6f9d8eadf2ae3cf5647ea3d7f8258ca Mon Sep 17 00:00:00 2001 From: Smaine Kahlouch Date: Mon, 3 Jul 2023 13:39:14 +0200 Subject: [PATCH 2/2] use list of secrets/configmaps for envFrom --- templates/server-deployment.yaml | 24 +++++++++++++++++++++--- templates/web-deployment.yaml | 8 ++++++-- values.yaml | 28 +++++++++++++++------------- 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/templates/server-deployment.yaml b/templates/server-deployment.yaml index fccea7c8..23adf649 100644 --- a/templates/server-deployment.yaml +++ b/templates/server-deployment.yaml @@ -121,15 +121,33 @@ spec: {{- if or $.Values.server.additionalEnv $serviceValues.additionalEnv }} {{- toYaml (default $.Values.server.additionalEnv $serviceValues.additionalEnv) | nindent 12 }} {{- end }} - {{- if or $serviceValues.additionalEnvCM $serviceValues.additionalEnvSecret }} + {{- if or $.Values.server.additionalEnvCM $.Values.server.additionalEnvSecret }} + envFrom: + {{- if $.Values.server.additionalEnvCM }} + {{- range $.Values.server.additionalEnvCM }} + - configMapRef: + name: {{ . }} + {{- end }} + {{- end }} + {{- if $.Values.server.additionalEnvSecret }} + {{- range $.Values.server.additionalEnvSecret }} + - secretRef: + name: {{ . }} + {{- end }} + {{- end }} + {{- else if or $serviceValues.additionalEnvCM $serviceValues.additionalEnvSecret }} envFrom: {{- if $serviceValues.additionalEnvCM }} + {{- range $serviceValues.additionalEnvCM }} - configMapRef: - name: {{ $serviceValues.additionalEnvCM }} + name: {{ . }} + {{- end }} {{- end }} {{- if $serviceValues.additionalEnvSecret }} + {{- range $serviceValues.additionalEnvSecret }} - secretRef: - name: {{ $serviceValues.additionalEnvSecret }} + name: {{ . }} + {{- end }} {{- end }} {{- end }} ports: diff --git a/templates/web-deployment.yaml b/templates/web-deployment.yaml index 014edc72..29d711e7 100644 --- a/templates/web-deployment.yaml +++ b/templates/web-deployment.yaml @@ -54,12 +54,16 @@ spec: {{- if or .Values.web.additionalEnvCM .Values.web.additionalEnvSecret }} envFrom: {{- if .Values.web.additionalEnvCM }} + {{- range .Values.web.additionalEnvCM }} - configMapRef: - name: {{ .Values.web.additionalEnvCM }} + name: {{ . }} + {{- end }} {{- end }} {{- if .Values.web.additionalEnvSecret }} + {{- range .Values.web.additionalEnvSecret }} - secretRef: - name: {{ .Values.web.additionalEnvSecret }} + name: {{ . }} + {{- end }} {{- end }} {{- end }} ports: diff --git a/values.yaml b/values.yaml index a5481712..d1246e3b 100644 --- a/values.yaml +++ b/values.yaml @@ -84,8 +84,8 @@ server: additionalVolumes: [] additionalVolumeMounts: [] additionalEnv: [] - additionalEnvCM: "" - additionalEnvSecret: "" + additionalEnvCM: [] + additionalEnvSecret: [] securityContext: fsGroup: 1000 runAsUser: 1000 @@ -185,8 +185,8 @@ server: tolerations: [] affinity: {} additionalEnv: [] - additionalEnvCM: "" - additionalEnvSecret: "" + additionalEnvCM: [] + additionalEnvSecret: [] containerSecurityContext: {} topologySpreadConstraints: {} podDisruptionBudget: {} @@ -209,8 +209,8 @@ server: tolerations: [] affinity: {} additionalEnv: [] - additionalEnvCM: "" - additionalEnvSecret: "" + additionalEnvCM: [] + additionalEnvSecret: [] containerSecurityContext: {} topologySpreadConstraints: {} podDisruptionBudget: {} @@ -233,8 +233,8 @@ server: tolerations: [] affinity: {} additionalEnv: [] - additionalEnvCM: "" - additionalEnvSecret: "" + additionalEnvCM: [] + additionalEnvSecret: [] containerSecurityContext: {} topologySpreadConstraints: {} podDisruptionBudget: {} @@ -257,8 +257,8 @@ server: tolerations: [] affinity: {} additionalEnv: [] - additionalEnvCM: "" - additionalEnvSecret: "" + additionalEnvCM: [] + additionalEnvSecret: [] containerSecurityContext: {} topologySpreadConstraints: {} podDisruptionBudget: {} @@ -280,8 +280,8 @@ admintools: tolerations: [] affinity: {} additionalEnv: [] - additionalEnvCM: "" - additionalEnvSecret: "" + additionalEnvCM: [] + additionalEnvSecret: [] resources: {} containerSecurityContext: {} securityContext: {} @@ -350,9 +350,11 @@ web: affinity: {} additionalEnv: [] + additionalEnvCM: [] + additionalEnvSecret: [] containerSecurityContext: {} - + securityContext: {} schema: