I made a design for my helm chart which uses templates to set certain parts of my kubernetes deployment. The templates are per cloud provider:
A template for GCE, a template for AWS, etc.
The template is then included into the deployment part of the chart in Helm.
Now there is a pretty way of doing this which is: Name every template according to the cloud provider it is intended for, and use a variable in the values.yaml to direct this.
And there is a less pretty way with a bunch of if statements.
I want to use the pretty way since it requires a lot less maintenance and code downstream, but can not get the following to work:
{{- include {{.Values.resources.cloudProvider}} .}}
In this statement the {{.Values.resources.cloudProvider}}
contains my cloud provider name (aws, gce, etc)
The error I get is:
Error: parse error in "testModel/templates/deployment.yaml":
template: testModel/templates/deployment.yaml:28:
unexpected "{" in operand
The other method I tested is:
{{- include (.Values.resources.cloudProvider) .}}
Which gives:
Error: render error in "testModel/templates/deployment.yaml": template:
testModel/templates/deployment.yaml:29:23:
executing "testModel/templates/deployment.yaml"
at <.Values.resources.c...>: invalid value; expected string
Is there a way to use a variable for a template name when including the template?
I am using helm 2.4.2. This work by changing the line
{{- include {{.Values.resources.cloudProvider}} .}}
to:
{{- include .Values.resources.cloudProvider .}}
You can also use a variable:
{{- $provider := .Values.resources.cloudProvider -}}
{{ - include $provider . }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With