title: helm - error converting YAML to JSON: yaml: line 29: mapping values are not allowed in this context
body: <p>Defined labels in temp with top of the same deployment.yml file-</p>
  <pre><code>{{- define &quot;chart.labels&quot; }} 
    version: v1.0
    method: http
    internet: enabled
  {{- end }}
  </code></pre>
  <p>I have deployment.yml file in template folder-</p>
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: app1-deployment
    namespace: {{ .Values.global.namespace }}
    labels:
      app: app1
      type: microservice1
  spec:
    replicas: 3
    selector:
      matchLabels:
        app: app1
        type: microservice1
    strategy:
      type: {{ .Values.global.strategytype }}
    template:
      metadata:
        labels:
          app: app1
          type: microservice1
          {{- template &quot;chart.labels&quot; }}
  </code></pre>
  <p>The Two ways - one from the keyword <em>template</em> (last line of the below code)</p>
  <p>And second one from the <em>include</em> keyword I am trying to call the template.</p>
  <pre><code>{{include &quot;chart.labels&quot; . | indent 8 }}
  </code></pre>
  <ul>
  <li>I am getting <strong>error</strong> ( when I am using keyword <em>template</em> to call
  the template).</li>
  </ul>
  <blockquote>
  <p>Error: YAML parse error on chart/templates/deployment.yml: error
  converting YAML to JSON: yaml: line 27: did not find expected key
  helm.go:81: [debug] error converting YAML to JSON: yaml: line 27: did
  not find expected key YAML parse error on
  chart/templates/deployment.yml
  helm.sh/helm/v3/pkg/releaseutil.(*manifestFile).sort
  helm.sh/helm/v3/pkg/releaseutil/manifest_sorter.go:146 helm.sh/helm/v3/pkg/releaseutil.SortManifests
  helm.sh/helm/v3/pkg/releaseutil/manifest_sorter.go:106 helm.sh/helm/v3/pkg/action.(*Configuration).renderResources
  helm.sh/helm/v3/pkg/action/action.go:165 helm.sh/helm/v3/pkg/action.(*Install).Run
  helm.sh/helm/v3/pkg/action/install.go:247</p>
  </blockquote>
  <ul>
  <li>Getting another <strong>error</strong> (when I use <em>Include</em> keyword to call the
  template)</li>
  </ul>
  <blockquote>
  <p>Error: YAML parse error on chart/templates/deployment.yml: error
  converting YAML to JSON: yaml: line 29: mapping values are not allowed
  in this context helm.go:81: [debug] error converting YAML to JSON:
  yaml: line 29: mapping values are not allowed in this context YAML
  parse error on chart/templates/deployment.yml
  helm.sh/helm/v3/pkg/releaseutil.(*manifestFile).sort
  helm.sh/helm/v3/pkg/releaseutil/manifest_sorter.go:146 helm.sh/helm/v3/pkg/releaseutil.SortManifests
  helm.sh/helm/v3/pkg/releaseutil/manifest_sorter.go:106 helm.sh/helm/v3/pkg/action.(*Configuration).renderResources
  helm.sh/helm/v3/pkg/action/action.go:165 helm.sh/helm/v3/pkg/action.(*Install).Run
  helm.sh/helm/v3/pkg/action/install.go:247 main.runInstall</p>
  </blockquote>
  <p>What am I missing here ?</p>