Dynamic ConfigMap Helm Template with nested curly braces

2/4/2019

I have the following files

mychart/templates/configmap.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Values.env.{{lle.dev}} }}-configmap
data:
  myvalue: "Hello World"

mychart/values.yaml

env:
  lle.dev: ABC
  lle.qa: CDE

How do I access the values in the helm template? nested curly braces are also not allowed. Also the below didn't work

name: {{ .Values.env.lle.dev }}-configmap

Reason being it is considering lle, dev as a separate sub keys for env and not as a single key.

-- k_vishwanath
kubernetes-helm

1 Answer

2/4/2019

Is there a reason you are trying to prefix your variables with lle? If not, you can rewrite your values.yaml file in the following way:

env:
  lle: 
    dev: ABC
    qa: CDE

Then you will be able to access your variables as in name: {{ .Values.env.lle.dev }}-configmap

-- edbighead
Source: StackOverflow