Use values from values.yaml inside named template in Helm v2/v3

1/16/2020

I cannot get a value from values.yaml inside named template section, but it is available outside of the section.

I would really appreciate if somebody can clarify what is wrong.

Helm 2 and Helm 3 have the same behaviour.

Simple example templates/test.yaml

{{- define "test" -}}
# Inside define section: {{ .Values.env }}
{{- end -}}
{{ template "test"}}
---
# Outside define section: {{ .Values.env}}

values.yaml

env: env-placeholder

Output

> helm template .
---
# Source: helm-configs-template/templates/test.yaml
# Inside define section:
---
# Source: helm-configs-template/templates/test.yaml
# Outside define section: env-placeholder
-- V.S.
kubernetes-helm

1 Answer

1/16/2020

I have found a solution to my question. I forgot to add a dot to

{{ template "test" .}}
-- V.S.
Source: StackOverflow