FATAL: password authentication failed for user "postgres" when using dependency charts for my own application

1/3/2019

I am able to run helm, postgresql chart without any dependencies by using the below command

helm install --name my-release \ --set postgresqlPassword=secretpassword,postgresqlDatabase=my-database \ stable/postgresql

But, when i run with a requirements.yaml file i am running out issues. Below is the snippet

dependencies: - name: postgresql repository: https://charts.bitnami.com/bitnami version: 3.7.1 i have added the env variable in deployment.yaml file spec: containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} env: - name: POSTGRES_HOST value: {{ template "postgresql.fullname" . }} - name: POSTGRES_PORT value: "5432" - name: POSTGRES_USERNAME value: {{ default "" .Values.postgresql.postgresqlUsername | quote }} - name: POSTGRES_PASSWORD value: {{ default "" .Values.postgresql.postgresqlPassword | quote }} - name: POSTGRES_DATABASE value: {{ default "" .Values.postgresql.postgresqlDatabase | quote }} ports: - containerPort: {{ .Values.service.internalPort }}

Added the values according to environmental variables declared in deployment.yaml file

postgresql: POSTGRES_DATABASE: ****** POSTGRES_USERNAME: postgres POSTGRES_PASSWORD: password

When i use helm install command helm install <chart-name>/ --name *** --set postgresqlDatabase=*****,postgresqlPassword=password

i am getting the following error as Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "postgres" at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:473) ~[postgresql-42.2.2.jar!/:42.2.2] at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:205) ~[postgresql-42.2.2.jar!/:42.2.2] at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.2.2.jar!/:42.2.2] at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195) ~[postgresql-42.2.2.jar!/:42.2.2] at org.postgresql.Driver.makeConnection(Driver.java:452) ~[postgresql-42.2.2.jar!/:42.2.2] at org.postgresql.Driver.connect(Driver.java:254) ~[postgresql-42.2.2.jar!/:42.2.2] at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:117) ~[HikariCP-2.7.8.jar!/:na] at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:123) ~[HikariCP-2.7.8.jar!/:na] at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:365) ~[HikariCP-2.7.8.jar!/:na] at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:194) ~[HikariCP-2.7.8.jar!/:na] at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:460) ~[HikariCP-2.7.8.jar!/:na] at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:534) ~[HikariCP-2.7.8.jar!/:na] at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) ~[HikariCP-2.7.8.jar!/:na] at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) ~[HikariCP-2.7.8.jar!/:na] at org.flywaydb.core.internal.util.jdbc.JdbcUtils.openConnection(JdbcUtils.java:51) ~[flyway-core-5.0.7.jar!/:na] ... 91 common frames omitted I am not sure how to assign the password for dependency postgresql. Is there a way to connect with postgres database.

-- klee
kubernetes
kubernetes-helm
postgresql

1 Answer

1/3/2019

What you are missing is something to set the password for the postgres instance that is embedded in your chart within in your values file, such as with an entry in the values like:

postgresql:
   postgresPassword: secretpassword 

Notice that this uses the camelcase name and not the all-uppercase as you are using. This will do the equivalent of setting the password via --set postgresql.postgresqlPassword=secretpassword. The value will be used by the bitnami postgresql chart to record its password within a secret. I'd suggest obtaining the password from that secret, though you could reference it directly in your Deployment as you are with .Values.postgresql.postgresqlPassword.

Either way you need to ensure you really do set it, either in the values with its name and not a uppercase name or as a parameter - I'd suggest putting a default in the values and you can override with a parameter.

To use the secret to get the password in the Deployment instead of .Values.postgresql.postgresqlPassword you would set the environment variable value with:

      valueFrom:
        secretKeyRef:
          name: {{ .Release.Name }}-postgresql
          key: postgres-password

Here {{ .Release.Name }}-postgresql should match the secret name that the postgresql chart uses.

(If an example helps the activiti runtime bundle chart uses postgres as a dependency (it gives it an alias) and it sets the postgres password in the values. It then retrieves the password and uses it in the deployment indirectly by reading the password from the secret that the postgres chart automatically creates, which can be referenced using the release name because the postgres chart names the secret using the template full name. This is based on the postgresql chart from the official kubernetes charts but as mentioned the bitnami chart creates a secret from a postgresqlPassword entry in the same way)

-- Ryan Dawson
Source: StackOverflow