<p>I have been trying to create postgresdb with the below yaml in kubernetes but running into below error</p>

<pre><code>The Deployment "postgres-airflow" is invalid: spec.template.spec.containers[0].volumeMounts[0].name: Not found: "postgres-vol"
</code></pre>

<p>can some please shed some light on this ? Not sure what i'm missing and it would be even more helpful if someone can let me know how to create dynamic volumes using azure fileshare as a storageClass. Any help would be greatly appreciated</p>

<p>Yaml file that i'm using to deploy postgres is below...</p>

<pre><code>kind: Deployment
apiVersion: apps/v1 
metadata:
  name: postgres-airflow
spec:
  replicas: 1 
  selector:
    matchLabels:
      name: postgres-airflow
  template:
    metadata:
      labels:
        name: postgres-airflow
    spec:
      restartPolicy: Always
      containers:
      - name: postgres
        image: postgres
        imagePullPolicy: IfNotPresent
        ports:
          - containerPort: 5432
            protocol: TCP
        volumeMounts:
        - mountPath: "/var/lib/postgresql/data/pgdata"
          name: postgres-vol
          subPath: pgdata
        env:
        - name: POSTGRES_USER
          value: root
        - name: POSTGRES_PASSWORD
          value: root
        - name: POSTGRES_DB
          value: airflow
        - name: PGDATA
          value: /var/lib/postgresql/data/pgdata
        - name: POD_IP
          valueFrom: { fieldRef: { fieldPath: status.podIP } }
        livenessProbe:
          initialDelaySeconds: 60
          timeoutSeconds: 5
          failureThreshold: 5
          exec:
            command:
            - /bin/sh
            - -c
            - exec pg_isready --host $POD_IP ||  if [[ $(psql -qtAc --host $POD_IP 'SELECT pg_is_in_recovery') != "f" ]]; then  exit 0 else; exit 1; fi
        readinessProbe:
          initialDelaySeconds: 5
          timeoutSeconds: 5
          periodSeconds: 5
          exec:
            command:
            - /bin/sh
            - -c
            - exec pg_isready --host $POD_IP
        resources:
          requests:
            ephemeral-storage: 5Gi
            memory: .5Gi
            cpu: .5
      volumes:
      - name: postgres-db-volume
        emptyDir: {}
</code></pre>

kick07
<p>In volumes you have <code>postgres-db-volume</code> but in volume mounts you have given <code>postgres-vol</code> which is not matching and leading to this error.</p>

<p><a href="https://learn.microsoft.com/en-us/azure/aks/azure-files-dynamic-pv" rel="nofollow noreferrer">Docs</a> on how to use azure file share for dynamic PV provisioning.</p>
