<p>I'm trying to upgrade a helm chart,</p>

<p>I get the error function "pod" not defined which make sense because I really have no such function.</p>

<p>The "pod" is coming from a json file which I convert into a configmap and helm is reading this value as a function and not as a straight string which is part of the json file.</p>

<p>This is a snippet of my configmap:</p>

<pre><code># Generated from 'pods' from https://raw.githubusercontent.com/coreos/prometheus-operator/master/contrib/kube-prometheus/manifests/grafana-dashboardDefinitions.yaml
# Do not change in-place! In order to change this file first read following link:
# https://github.com/helm/charts/tree/master/stable/prometheus-operator/hack
{{- if and .Values.grafana.enabled .Values.grafana.defaultDashboardsEnabled }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ printf "%s-%s" (include "prometheus-operator.fullname" $) "services-health" | trunc 63 | trimSuffix "-" }}
  labels:
    {{- if $.Values.grafana.sidecar.dashboards.label }}
    {{ $.Values.grafana.sidecar.dashboards.label }}: "1"
    {{- end }}
    app: {{ template "prometheus-operator.name" $ }}-grafana
{{ include "prometheus-operator.labels" $ | indent 4 }}
data:
  services-health.json: |-
    {
      "annotations": {
        "list": [
          {
            "builtIn": 1,
            "datasource": "-- Grafana --",
            "enable": true,
            "hide": true,
            "iconColor": "rgba(0, 211, 255, 1)",
            "name": "Annotations &amp; Alerts",
            "type": "dashboard"
          }
        ]
      },
      "targets": [
        {
          "expr": "{__name__=~\"kube_pod_container_status_ready\", container=\"aggregation\",kubernetes_namespace=\"default\",chart=\"\"}",
          "format": "time_series",
          "instant": false,
          "intervalFactor": 2,
          "legendFormat": "{{pod}}",
          "refId": "A"
        }
}
{{- end }}
</code></pre>

<p>The error I get is coming from this line: <strong>"legendFormat": "{{pod}}",</strong></p>

<p>And this is the error I get:</p>

<blockquote>
  <p>helm upgrade --dry-run prometheus-operator-chart
  /home/ubuntu/infra-devops/helm/vector-chart/prometheus-operator-chart/
      Error: UPGRADE FAILED: parse error in "prometheus-operator/templates/grafana/dashboards/services-health.yaml":
  template:
  prometheus-operator/templates/grafana/dashboards/services-health.yaml:1213:
  function "pod" not defined</p>
</blockquote>

<p>I tried to escape it but nothing worked.
Anyone get idea about how I can work around this issue?</p>

Shahar Hamuzim Rajuan
<p>Escaping gotpl placeholders is possible using <a href="https://github.com/helm/helm/issues/2798#issuecomment-467319526" rel="noreferrer">backticks</a>. For example, in your scenario, instead of using <code>{{ pod }}</code> you could write <code>{{` {{ pod }} `}}</code>.</p>
