<p><strong>Getting error</strong>
postgres deployment for service is getting fail. Checked yaml with yamllint and it is valid, but still getting the error. Deployment file contains ServiceAccount , Service and Statefulset.</p>
<pre><code>install.go:158: [debug] Original chart version: &quot;&quot;
install.go:175: [debug] CHART PATH: /builds/xxx/xyxy/xyxyxy/xx/xxyy/src/main/helm
Error: YAML parse error on postgresdeployment.yaml: error converting YAML to JSON: yaml: line 24: did not find expected key
helm.go:75: [debug] error converting YAML to JSON: yaml: line 24: did not find expected key
YAML parse error on postgresdeployment.yaml
helm.sh/helm/v3/pkg/releaseutil.(*manifestFile).sort
    /home/circleci/helm.sh/helm/pkg/releaseutil/manifest_sorter.go:146
helm.sh/helm/v3/pkg/releaseutil.SortManifests
    /home/circleci/helm.sh/helm/pkg/releaseutil/manifest_sorter.go:106
helm.sh/helm/v3/pkg/action.(*Configuration).renderResources
    /home/circleci/helm.sh/helm/pkg/action/install.go:489
helm.sh/helm/v3/pkg/action.(*Install).Run
    /home/circleci/helm.sh/helm/pkg/action/install.go:230
main.runInstall
    /home/circleci/helm.sh/helm/cmd/helm/install.go:223
main.newUpgradeCmd.func1
    /home/circleci/helm.sh/helm/cmd/helm/upgrade.go:113
github.com/spf13/cobra.(*Command).execute
    /go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:826
github.com/spf13/cobra.(*Command).ExecuteC
    /go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:914
github.com/spf13/cobra.(*Command).Execute
    /go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:864
main.main
    /home/circleci/helm.sh/helm/cmd/helm/helm.go:74
runtime.main
    /usr/local/go/src/runtime/proc.go:203
runtime.goexit
    /usr/local/go/src/runtime/asm_amd64.s:1357
    
</code></pre>
<p><strong>postgresdeployment.yaml</strong></p>
<ol>
<li>Is there is any invalid yaml syntax?</li>
<li>Any indentation is missing ?</li>
<li>Which node is missing here?</li>
</ol>
<pre><code>{{- if contains &quot;-dev&quot; .Values.istio.suffix }}
# Postgre ServiceAccount
apiVersion: v1
kind: ServiceAccount
metadata:
  name: postgres
---
# PostgreSQL StatefulSet Service
apiVersion: v1
kind: Service
metadata:
  name: postgres
  labels:
    app: postgres
spec:
  selector:
    app: postgres
  ports:
    - port: 5432
      targetPort: 5432
---
# Postgre StatefulSet
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: postgres
spec:
  selector:
    matchLabels:
      app: postgres
  replicas: {{ .Values.replicaCount }}
  template:
    metadata:
      labels:
        app: postgres
    spec:
        serviceAccountName: postgres
        securityContext:
          {{- toYaml .Values.securityContext | nindent 8 }}
        terminationGracePeriodSeconds: {{ default 60 .Values.terminationGracePeriodSeconds }}
        volumes:
        {{ include &quot;xxx.volumes.logs.spec&quot; . | indent 8 }}
        - emptyDir: { }
            name: postgres-disk
        containers:
          - name: postgres
            image: &quot;{{ template &quot;xxx.dockerRegistry.hostport&quot; . }}/postgres:latest&quot;
            imagePullPolicy: {{ .Values.image.pullPolicy }}
            ports:
              - name: postgres
                containerPort: 5432
            livenessProbe:
              tcpSocket:
                port: 5432
              failureThreshold: 3
              initialDelaySeconds: 240
              periodSeconds: 45
              timeoutSeconds: 5
            readinessProbe:
              tcpSocket:
                port: 5432
              failureThreshold: 2
              initialDelaySeconds: 180
              periodSeconds: 5
              timeoutSeconds: 20
            resources:
              {{ if .Values.lowResourceMode }}
                {{- toYaml .Values.resources.low | nindent 12 }}
                {{ else }}
                {{- toYaml .Values.resources.high | nindent 12 }}
                {{ end }}
            env:
              - name: PGDATA
                value: /var/lib/postgresql/data/pgdata
            volumeMounts:
              - name: postgres-disk
                mountPath: /var/lib/postgresql/data
{{- end }}
</code></pre>

Yashika Chandra
<p>The templating mustaches in helm (and its golang text/template peer) must be one token, otherwise yaml believes that <code>{</code> opens a dict, and then <code>{</code> tries to open a <em>child</em> dict and just like in JSON that's not a valid structure</p>
<p>So you'll want:</p>
<pre class="lang-yaml prettyprint-override"><code>        serviceAccountName: postgres
        securityContext:
          {{- toYaml .Values.securityContext | nindent 8 }}
</code></pre>
