<p>I don't really know what is the error here, is a simple helm deploy with a _helpers.tpl, it doesn't make sense and is probably a stupid mistake, the code:</p>
<p>deploy.yaml</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
{{ include &quot;metadata.name&quot; . }}-deploy
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 2 # tells deployment to run 2 pods matching the template
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
        vars: {{- include &quot;envs.var&quot; .Values.secret.data }}
</code></pre>
<p>_helpers.tpl</p>
<pre class="lang-yaml prettyprint-override"><code>{{- define &quot;envs.var&quot;}}
{{- range $key := . }}
- name: {{ $key | upper | quote}}
  valueFrom:
    secretKeyRef:
      key: {{ $key | lower }}
      name: {{ $key }}-auth
{{- end }}
{{- end }}
</code></pre>
<p>values.yaml</p>
<pre class="lang-yaml prettyprint-override"><code>secret:
  data:
    username: root
    password: test
</code></pre>
<p>the error</p>
<pre><code>Error: YAML parse error on mychart/templates/deploy.yaml: error converting YAML to JSON: yaml: line 21: did not find expected key
</code></pre>

Juan.
<p>Here this problem happens because of indent. You can resolve by updating</p>
<pre><code>env: {{- include &quot;envs.var&quot; .Values.secret.data | nindent 12  }}
</code></pre>
