<p>I'm trying to write the K8s syntax for declaring a secret in a file, then mounting it in an accessible way. In short, in the simplest way, I want to store Postgres credentials (client key, client cert, server-ca cert) in files. When I try to install, it can't find the volume. I <em>thought</em> the volume is defined in the deployment YAML attached below.</p>
<p>How do I tell Helm/K8s that yes, these secrets should be mounted as volumes, create them if needed?</p>
<p>My secrets defined:</p>
<pre><code>&gt;kubectl get secrets |grep postgres
postgres-client-cert                             Opaque                                1      20m
postgres-client-key                              Opaque                                1      18m
postgres-server-ca                               Opaque                                1      18m
</code></pre>
<p>Failed attempt to deploy chart:</p>
<pre><code>helm upgrade --install $APP-$TARGET_ENV ./.helm -f ./.helm/values-$TARGET_ENV.yaml -n $TARGET_ENV 
W0609 18:56:15.653459 1198995 gcp.go:120] WARNING: the gcp auth plugin is deprecated in v1.22+, unavailable in v1.25+; use gcloud instead.
To learn more, consult https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke
Error: UPGRADE FAILED: cannot patch &quot;myapp-app&quot; with kind Deployment: Deployment.apps &quot;myapp-app&quot; is invalid: [spec.template.spec.containers[0].volumeMounts[1].name: Not found: &quot;postgres-client-key-volume&quot;, spec.template.spec.containers[0].volumeMounts[2].name: Not found: &quot;postgres-server-ca-volume&quot;]
</code></pre>
<p>.helm/templates/deployment.yaml:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Chart.Name }}
  labels:
    app: {{ .Chart.Name }}
    {{- include &quot;app.labels&quot; . | nindent 4 }}
spec:
  {{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount | default 1 }}
  {{- end }}
  selector:
    matchLabels:
      {{- include &quot;app.selectorLabels&quot; . | nindent 6 }}
  template:
    metadata:
      {{- with .Values.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      labels:
        {{- include &quot;app.selectorLabels&quot; . | nindent 8 }}
    spec:
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      serviceAccountName: {{ .Chart.Name }}
      securityContext:
        {{- toYaml .Values.podSecurityContext | nindent 8 }}
      containers:
        - name: {{ .Chart.Name }}
          env:
            - name: TIME_UPDATED
              value: {{ now | date &quot;2006-01-02T15:04:05&quot; }}
            - name: SENTRY_ENV
              value: {{ .Values.deployment.SENTRY_ENV }}
            - name: PORT
              value: {{ .Values.deployment.containerPort | quote }}
            {{- toYaml .Values.deployment.env | nindent 12 }}
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: &quot;{{ .Values.image.repository }}:{{ .Values.image.sha1 | default .Chart.AppVersion }}&quot;
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          volumeMounts:
          - name: postgres-client-cert-volume 
            mountPath: &quot;/var/run/secrets/postgres-client-cert&quot;
            readOnly: true
          - name: postgres-client-key-volume 
            mountPath: &quot;/var/run/secrets/postgres-client-key&quot;
            readOnly: true
          - name: postgres-server-ca-volume 
            mountPath: &quot;/var/run/secrets/postgres-server-ca&quot;
            readOnly: true
          ports:
            - name: http
              containerPort: {{ .Values.deployment.containerPort }}
              protocol: TCP
          livenessProbe:
            {{- toYaml .Values.livenessProbe | nindent 12 }}
          readinessProbe:
            {{- toYaml .Values.readinessProbe | nindent 12 }}
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
      volumes:
        - name: postgres-client-cert-volume
          secret:
              secretName: postgres-client-cert
              optional: false
        - name: postgres-client-key
          secret:
              secretName: postgres-client-key
              optional: false
        - name: postgres-server-ca
          secret:
              secretName: postgres-server-ca
              optional: false
             
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
</code></pre>

Woodsman
<p>The helm chart is looking for a mount named postgres-server-ca-volume but you've got it named postgres-server-ca on line 74</p>
