Skip to content

Instantly share code, notes, and snippets.

@nepomucen
Last active April 21, 2020 10:09
Show Gist options
  • Save nepomucen/14e99543652c5f5284688ff05b0b7837 to your computer and use it in GitHub Desktop.
Save nepomucen/14e99543652c5f5284688ff05b0b7837 to your computer and use it in GitHub Desktop.
helm template - let users introduce their custom ENVs based on ConfigMap in supported resources
env:
- name: POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
{{- if .Values.envConfigs }}
{{- range $key, $config := $.Values.envConfigs }}
- name: {{ $key }}
valueFrom:
configMapKeyRef:
name: {{ $config }}
key: {{ $key | quote }}
{{- end }}
{{- end }}
#
# values.yaml
#
envConfigs:
Q3_CFG_MAP: Q3DM17
Q3_CFG_TIMEOUT: 30
# if empty use:
# envConfigs: {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment