Helm Conditional Templates
I discovered that empty templates are not loaded. I solved it by wrapping my yaml file content in an if
condition.
{{ if .Values.something }}
content of yaml file
{{ end }}
You simply wrap the template resource at the first and last lines with the check you want to do. Let's take the official Grafana chart as example:
In its values.yaml
, it has a flag called ingress.enabled
, which looks like the following:
ingress:
enabled: false
Then in its ingress template resource, this flag is checked:
{{- if .Values.ingress.enabled -}}
...
apiVersion: extensions/v1beta1
kind: Ingress
...
{{- end }}
As a result, ingress object will only be created if ingress.enabled
is set to true.