helmfile
helmfile copied to clipboard
Reference other variables in values.yaml.gotmpl
Hi,
I would like to achieve something like the below.
values.yaml.gotmpl
customer: xxxxx
domain: {{ .Values.customer }}.example.com
This obviously does not work. Is there another way to reference a previous variable in values.yaml.gotmpl
that I'm missing?
Thanks!
Try to use the recommendation from this document: https://github.com/roboll/helmfile/blob/master/docs/writing-helmfile.md#layering-state-template-files - something like this:
customer: xxxxx
---
domain: {{ .Values.customer }}.example.com
Hi @mumoshu, Hi @MurzNN
I would like to add my question here, I hope that's fine.
Is this also possible with environment values? Can I use Go templating and the state layering there? What I'm trying to do is something like:
org:
keyvault:
kv1: org-kv1.vault.azure.net
---
org:
database:
postgres96:
host: ref+azurekeyvault://{{ .Values.org.keyvault.kv1 }}/azure-postgresql-96-host
user: ref+azurekeyvault://{{ .Values.org.keyvault.kv1 }}/azure-postgresql-96-user
...
postgres11:
host: ref+azurekeyvault://{{ .Values.org.keyvault.kv1 }}/azure-postgresql-11-host
user: ref+azurekeyvault://{{ .Values.org.keyvault.kv1 }}/azure-postgresql-11-user
...
But it does not work. I get something like:
err: failed to read helmfile.yaml: failed to load environment values file "environments/dev.yaml.gotmpl": failed to render [environments/dev.yaml.gotmpl], because of template: stringTemplate:17:42: executing "stringTemplate" at <.Values.org.keyvault.kv1>: map has no entry for key "org"
Any help would be very appreciated. Thank you!
Hi, Currently I have the same problem like @pathob
helmfile.yaml
releases:
- name: myservice
namespace: test
chart: chart/parent
values:
- values.yaml.gotmpl
values.yaml.gotmpl
customer: xxxxx
---
domain: {{ .Values.customer }}.example.com
this leads to the following errors @MurzNN
helmfile write-values
> ... in ./helmfile.yaml: failed to render values files "values.yaml.gotmpl": failed to render [values.yaml.gotmpl], because of template: stringTemplate:3:18:
executing "stringTemplate" at <.Values.customer>: map has no entry for key "customer"
Thanks for your support.
@pathob @Ro-Fo Hey! As far as I remember, I don't think ---
was supported in values file templates.
It's supported in helmfile.yaml templates so all I can say is that you'd better handle such "layering" in helmfile yamls, not values templates.
You could also try combining dict
, merge
, readFile
, and fromYaml
to merge objects, and finally outputting yaml by piping the result to toYaml
in your values template.