15

I install the Bitnami Helm chart, using the example shown in the README:

helm install my-db \
  --namespace dar \
  --set postgresqlPassword=secretpassword,postgresqlDatabase=my-database \
  bitnami/postgresql

Then, following the instructions shown in the blurb which prints after the installation is successful I forward the port to port 5432 then try and connect:

PGPASSWORD="secretpassword" psql --host 127.0.0.1 -U postgres -d my-database -p 5432

But I get the following error:

psql: error: could not connect to server: FATAL:  password authentication failed for user "postgres"

How can this be? Is the Helm chart buggy?

2 Answers 2

53

Buried deep in the stable/postgresql issue tracker is the source of this very-hard-to-debug problem.

When you run helm uninstall ... it errs on the side of caution and doesn't delete the storage associated with the database you got when you first ran helm install ....

This means that once you've installed Postgres once via Helm, the secrets will always be the same in subsequent installs, regardless of what the post-installation blurb tells you.

To fix this, you have to manually remove the persistent volume claim (PVC) which will free up the database storage.

kubectl delete pvc data-my-db-postgresql-0

(Or whatever the PVC associated with your initial Helm install was named.)

Now a subsequent helm install ... will create a brand-new PVC and login can proceed as expected.

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

5 Comments

Yes I also have run into the same problem once and deleting the PVC fixed it..
Thanks a lot, Almost tried a day your post helped me lot to fix the issue as 'kubectl delete pvc <pvc>' command
Thank you, my friend!! This pvc being retained issue is notorious!
Thanks a lot. This has rescued me from half of day debugging.
You are a lifesaver
0

I had the same issue but wasn't able anymore to drop the PVC as we were running in prod from a restore.

I ended up updating the password as described here:

sudo -u postgres psql

\password postgres

Comments

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.