How an helm chart have an attribute with value contain {{ }}

11/9/2017

In a helm chart, we can define value as something like {{ Values.name }}, which will be replaced by the real value defined in values.yaml. But if the original value has the similar format such as {{name}}, when trying to install that chart, it will fail due to error that "name" is not defined. Is there any way to handle this?

-- Marco
kubernetes-helm

2 Answers

3/5/2020

You can embed it as a literal string with backticks:

{{`{{ "name" }}`}}
-- Steve Buzonas
Source: StackOverflow

11/9/2017

You can escape double curly brackets in Go templates using {{ "{{" }}.

But the best way is embedding the alerting rules as separate files:

apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ template "fullname" . }}-rules
  labels:
    chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
    prometheus: {{ template "fullname" . }}
data:
  {{ (.Files.Glob "rules/*").AsConfig | indent 2 }}
-- nickgryg
Source: StackOverflow