I want to choose config section from values.yaml by setting a variable in helm command line.
example part of values.yaml:
aaa:
x1: "az1"
x2: "az2"
bbb:
x1: "bz1"
x2: "bz2"
example part of configmap.yaml
data:
{{ .Values.outsideVal.x1 }}
Expected result should looks like this
data:
az1
Test helm output
helm template --set outsideVal=aaa mychart
And got this error
Error: render error in "./templates/configmap.yaml": template: ./templates/configmap.yaml:21:12: executing "./templates/configmap.yaml" at <.Values.outsideVal.x...>: can't evaluate field x1 in type interface {}
So the question is how get the result as expected?
I suspect you're looking for the text/template index
function, which can look up a value in a map by a variable key.
{{ (index .Values .Values.outsideVal).x1 }}