Setting pointers in values.yaml

11/12/2020
prometheus:
  target2: &target2 "x.x.x.x:31080"

This is a part of the values.yaml in my charts. I want to be able to set it through helm --set. Something like this:

helm upgrade grap . --set prometheus.target2="&target2 \"1.1.1.1:31080\""

But, the above is not working. Please let me know how it can be possible.

-- Guna K K
kubernetes
kubernetes-helm

1 Answer

11/13/2020

Unfortunately this is not going to work since --set treats your parameter as string and not as anchor. I was wondering if this would work with --values but my test was not successful and the anchor was not propagated.

Here is the example where I tried to use --values :

#templates/file.yaml 
A: {{ .Values.asd }} 
B: {{ .Values.qwe }}

values.yaml 
asd: &anch 123 
qwe: *anch

The values before patch:

helm template .

Source: asdasd/templates/file.yaml 
A: 123 
B: 123

Here we place the patch using --values:

helm template . --values <(cat << EOF 
asd: &anch 789
EOF 
)

And the result of it:

--- 
#Source: asdasd/templates/file.yaml 
A: 789 
B: 123

As you can see after the patch and decoding the anchor is being lost.

Worth to mention here is that Helm and K8s very often read, modify and rewrite yaml, so after decoding the anchors will be lost. Helm docs describes this here.

-- acid_fuji
Source: StackOverflow