I'm using helmfile
to install my Helm chart and other dependencies charts.
I want to use templated values in the value files.
From this resolved issue, it looks like templating in value files is supported. However, I tested with the following files:
helmfile.yaml
:
environments:
default:
values:
- my:
port: 8080
---
repositories:
- name: incubator
url: https://kubernetes-charts-incubator.storage.googleapis.com
releases:
- name: haproxy-ingress
namespace: haproxy-ingress
chart: incubator/haproxy-ingress
version: 0.0.27
values:
- values.yaml
values.yaml
:
controller:
tcp:
1936: "my_namespace/my-service:{{ .Values.my.port }}"
And if I run helmfile template
, I would get
COMBINED OUTPUT:
Error: template: haproxy-ingress/templates/tcp-configmap.yaml:16:31: executing "haproxy-ingress/templates/tcp-configmap.yaml" at <tpl $value $>: error calling tpl: error during tpl function execution for "my_namespace/my-service:{{ .Values.my.port }}": template: haproxy-ingress/templates/tcp-configmap.yaml:1:34: executing "haproxy-ingress/templates/tcp-configmap.yaml" at <.Values.my.port>: nil pointer evaluating interface {}.port
Use --debug flag to render out invalid YAML
If I inline the values, it works
environments:
default:
values:
- my:
port: 8080
---
repositories:
- name: incubator
url: https://kubernetes-charts-incubator.storage.googleapis.com
releases:
- name: haproxy-ingress
namespace: haproxy-ingress
chart: incubator/haproxy-ingress
version: 0.0.27
values:
- controller:
tcp:
1936: "my_namespace/my-service:{{ .Values.my.port }}"
I got the answer. From the document of helmfile,
Therefore, for this case,
values.yaml
should be renamed tovalues.yaml.gotmpl
so that helmfile will interpret the file as go template.