0

I have values.yaml like below

 configMap:
  data:
    dev:
      ATTR1 : "Value1-dev"
      ATTR2 : "Value2-dev"
    qa:
      ATTR1 : "Value1-qa"
      ATTR2 : "Value2-qa"

My configMap template is like below

apiVersion: v1
kind: ConfigMap
metadata:
  name: "{{ .Values.service.name }}-configmap"
data:
  ATTR1 : "{{ .Values.configMap.data.<env>.ATTR1 }}"
  ATTR2: "{{ .Values.configMap.data.<env>.ATTR2 }}"

Is there any way I can dynamically pass the "env" value to populate data for different environment?

Angshuman
  • 225
  • 3
  • 17
  • The easiest way to do this IMHO is to use a separate values file per environment; run `helm install -f values.dev.yaml`, and in those separate files have `configMap: { data: { ... } }` without the per-environment layer. With the layout you show here you can also use the `index` template function. – David Maze Nov 24 '21 at 15:52
  • Does this answer your question? [Access a map value using a variable key in a Go template](https://stackoverflow.com/questions/26152088/access-a-map-value-using-a-variable-key-in-a-go-template) – David Maze Nov 24 '21 at 15:52

0 Answers0