From 8faeee5594e08a1eef4acdb68cdf1f7bb18b0e32 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Thu, 14 Nov 2024 08:25:23 +0100 Subject: [PATCH] add env --- templates/deployment.yaml | 29 +++++++++++++++++++++++++++++ values.yaml | 30 ++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 0194f64..0dab941 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -24,6 +24,35 @@ spec: volumeMounts: - name: data mountPath: /data + env: + {{- with .Values.env.plain }} + {{- toYaml . | nindent 12 }} + {{- end }} + {{- range .Values.env.configMapKeys }} + - name: {{ .name }} + valueFrom: + configMapKeyRef: + name: {{ .configMapName }} + key: {{ .key }} + {{- end }} + {{- range .Values.env.secretKeys }} + - name: {{ .name }} + valueFrom: + secretKeyRef: + name: {{ .secretName }} + key: {{ .key }} + {{- end }} + envFrom: + {{- range .Values.env.configMapRefs }} + - configMapRef: + name: {{ .name }} + optional: {{ .optional | default false }} + {{- end }} + {{- range .Values.env.secretRefs }} + - secretRef: + name: {{ .name }} + optional: {{ .optional | default false }} + {{- end }} volumes: - name: data persistentVolumeClaim: diff --git a/values.yaml b/values.yaml index 745148c..4aa7a16 100644 --- a/values.yaml +++ b/values.yaml @@ -35,3 +35,33 @@ ingress: # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" # cert-manager.io/cluster-issuer: "letsencrypt-prod" + + +# Environment variables to be passed to the container +env: + # Direct environment variables + plain: + - name: APP_NAME + value: "my-app" + - name: PORT + value: "8080" + + # Environment variables from ConfigMaps + configMapRefs: + - name: app-config # Reference an existing ConfigMap + optional: true # Make it optional + + configMapKeys: + - name: CONFIG_KEY + configMapName: app-config + key: config.key + + # Environment variables from Secrets + secretRefs: + - name: app-secrets # Reference an existing Secret + optional: true # Make it optional + + secretKeys: + - name: API_KEY + secretName: app-secrets + key: api.key