values.yaml
## One may define arbitrary environment variables here
env:
VARIABLE_ONE: "Foo"
VARIABLE_TWO: ""
## List of all environment variables that are required by this helm chart
requiredEnvs:
- VARIABLE_ONE
- VARIABLE_TWO
templates/configmap.yaml
{{- if or .Values.env .Values.requiredEnvs -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "mychart.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "mychart.name" . }}
helm.sh/chart: {{ include "mychart.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
data:
{{- /* Test if all required environment variables are set */ -}}
{{- range $idx, $key := .Values.requiredEnvs -}}
{{- $_ := required (printf "A valid .Values.env.%s entry is required!" $key) (index $.Values.env $key) -}}
{{- end - }}
{{/* Include all environment variabled in this ConfigMap */}}
{{- range $key, $val := .Values.env }}
{{ $key | upper }}: {{ $val | quote }}
{{- end }}
{{- end }}