Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Helm Postgres password authentication failed

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?

like image 512
LondonRob Avatar asked Sep 16 '20 09:09

LondonRob


1 Answers

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.

like image 184
LondonRob Avatar answered Sep 28 '22 18:09

LondonRob