<p>I'm using Helm to deploy postgres on Kubernetes cluster. I create a persistent volume and a persistent volume claim:</p>
<p>pv.yaml:</p>
<pre>

    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: task-pv-volume
      labels:
        type: local
    spec:
      storageClassName: manual
      capacity:
        storage: 10Gi
      accessModes:
        - ReadWriteMany
      hostPath:
        path: "/mnt/data"

</pre>
<p>pvc.yaml:</p>
<pre>

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: task-pv-claim
    spec:
      storageClassName: manual
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 8Gi

</pre>
<p>and run helm with command:</p>
<p><code> helm install my-release stable/postgresql --set persistence.existingClaim=task-pv-claim</code></p>
<p>but Pods is in state CrashLoopBackOff. Logs of the pod say:</p>
<pre>

    postgresql 12:12:18.62 
    postgresql 12:12:18.62 Welcome to the Bitnami postgresql container
    postgresql 12:12:18.62 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-postgresql
    postgresql 12:12:18.62 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-postgresql/issues
    postgresql 12:12:18.63 Send us your feedback at containers@bitnami.com
    postgresql 12:12:18.63 
    postgresql 12:12:18.65 INFO  ==> ** Starting PostgreSQL setup **
    postgresql 12:12:18.73 INFO  ==> Validating settings in POSTGRESQL_* env vars..
    postgresql 12:12:18.73 INFO  ==> Loading custom pre-init scripts...
    postgresql 12:12:18.74 INFO  ==> Initializing PostgreSQL database...
    mkdir: cannot create directory ‘/bitnami/postgresql/data’: Permission denied
    postgresql 12:12:18.76 INFO  ==> Stopping PostgreSQL...

</pre>
<p>How can i fix it?</p>

<p>Try setting the helm charts <code>volumePermissions.enabled</code> to true.</p>
<p>Sometimes the cluster settings don't give the running container enough permissions to actuall write to the mounted volume by default.</p>
