5

I'm using Helm to deploy postgres on Kubernetes cluster. I create a persistent volume and a persistent volume claim:

pv.yaml:

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

pvc.yaml:

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

and run helm with command:

helm install my-release stable/postgresql --set persistence.existingClaim=task-pv-claim

but Pods is in state CrashLoopBackOff. Logs of the pod say:

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 [email protected]
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...

How can i fix it?

5
  • You mount the PV to the path /mnt/data, but your PSQL Instance searches for it in bitnami/postgresql/data. Maybe try setting bitnami/postgresql/data as the hostPath.path variable. Commented Aug 6, 2020 at 12:24
  • 1
    Sorry, my mistake. I mistook your first config for the Statefulest -_- In that case at least the config seems correct. Are there some default security settings inr your cluster? Have you tried setting the helm charts setting volumePermissions.enabled to true?? Commented Aug 6, 2020 at 12:39
  • 1
    it works, thanks a lot Commented Aug 6, 2020 at 12:58
  • 1
    Sure thing. Let me add it as an answer, so people looking into this later see what fixed the problem. Commented Aug 6, 2020 at 13:02
  • @pado can you please share description of your storageclass? are you using local volume? Commented Jan 25, 2023 at 15:14

1 Answer 1

22

Try setting the helm charts volumePermissions.enabled to true.

Sometimes the cluster settings don't give the running container enough permissions to actuall write to the mounted volume by default.

Sign up to request clarification or add additional context in comments.

2 Comments

Worked for me by adding --set volumePermissions.enabled=true to the helm install command. Thank you!
doesnt work with this value to my postgre helm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.