Failing to connect to the postgress statefulset database installed from stable/postgresql helm chart

4/6/2019

Do you guys have played with the stable/postgresql helm chart?

I successfully install the release using this command within a GKE context

$helm install --name pg-set -f ./values-production.yaml stable/postgresql --set postgresqlDatabase=nixmind-db

It went fine, but I can't further connect to my cluster for ckeck/tests..., cause it fails connecting to the database due to password.

I tried all the following way but got the same error :

$export POSTGRES_PASSWORD=$(kubectl get secret --namespace default pg-set-postgresql -o jsonpath="{.data.postgresql-password}" | base64 --decode)
$kubectl run pg-set-postgresql-client --rm --tty -i --restart='Never' --namespace default --image docker.io/bitnami/postgresql:10.7.0 --env="PGPASSWORD=$POSTGRES_PASSWORD" --command -- psql --host pg-set-postgresql -U postgres -d nixmind-db

psql: FATAL: password authentication failed for user "postgres" pod "pg-set-postgresql-client" deleted pod default/pg-set-postgresql-client terminated (Error)

$export POSTGRES_PASSWORD=$(kubectl get secret --namespace default pg-set-postgresql -o jsonpath="{.data.postgresql-password}" | base64 --decode)
$kubectl run pg-set-postgresql-client --rm --tty -i --restart='Never' --namespace default --image docker.io/bitnami/postgresql:10.7.0 --env="POSTGRESS_PASSWORD=$POSTGRES_PASSWORD" --command -- psql --host pg-set-postgresql -U postgres -d nixmind-db

psql: FATAL: password authentication failed for user "postgres" pod "pg-set-postgresql-client" deleted pod default/pg-set-postgresql-client terminated (Error)

$export POSTGRES_PASSWORD=$(kubectl get secret --namespace default pg-set-postgresql -o jsonpath="{.data.postgresql-password}" | base64 --decode)
$kubectl run pg-set-postgresql-client --tty -i --restart='Never' --namespace default --image docker.io/bitnami/postgresql:10.7.0 --env="POSTGRESQL_PASSWORD=$POSTGRES_PASSWORD" --command -- psql --host pg-set-postgresql -U postgres -d nixmind-db

If you don't see a command prompt, try pressing enter.

psql: fe_sendauth: no password supplied pod default/pg-set-postgresql-client terminated (Error)

$export POSTGRES_PASSWORD=$(kubectl get secret --namespace default pg-set-postgresql -o jsonpath="{.data.postgresql-password}" | base64 --decode)
$kubectl run pg-set-postgresql-client --tty -i --restart='Never' --namespace default --image docker.io/bitnami/postgresql:10.7.0 --env="POSTGRESQL_PASSWORD=$POSTGRES_PASSWORD" --command -- psql --host pg-set-postgresql -U postgres -d nixmind-db

If you don't see a command prompt, try pressing enter.

psql: fe_sendauth: no password supplied pod default/pg-set-postgresql-client terminated (Error)

Thy to connect localy to the client and run the command

$kubectl run pg-set-postgresql-client --tty -i --restart='Never' --namespace default --image docker.io/bitnami/postgresql:10.7.0 --env="POSTGRES_PASSWORD=$POSTGRES_PASSWORD" --command -- /bin/bash

If you don't see a command prompt, try pressing enter.

I have no name!@pg-set-postgresql-client:/$ env
.............................................................................
POSTGRESQL_PASSWORD=m7RWxRvpSk
POSTGRESQL_USERNAME=postgres
POSTGRESQL_NUM_SYNCHRONOUS_REPLICAS=0
POSTGRESQL_INITDB_ARGS=
KUBERNETES_SERVICE_HOST=10.63.240.1
NAMI_VERSION=1.0.0-1
.............................................................................
I have no name!@pg-set-postgresql-client:/$ psql --host pg-set-postgresql -U postgres -d nixmind-db

Password for user postgres: psql: FATAL: password authentication failed for user "postgres"

It seems to be a problem being submitted several time, but without real solution... How do you guys test this release after installation? What am I missing? Is the password retrieved from the cluster secrets the one configured on the master database? May be this command psql --host pg-set-postgresql -U postgres -d nixmind-db tries to access the slave and not master really? Why the psql client doesn't even read the password from environment variables as expected?

-- nixmind
kubectl
kubernetes
kubernetes-helm
kubernetes-statefulset

1 Answer

4/6/2019

It's all OK.

I was characters issue with my terminal, the password retrieved from cluster credentials is the good one, and the database is accessible.

-- nixmind
Source: StackOverflow