I’m deploying a Quarkus application in Kubernetes, and it fails to connect to the PostgreSQL database with the following error:
FATAL: password authentication failed for user "<username>"
Here’s some background on my setup:
Database Configuration:
The database credentials are injected via Helm using --set flags in a GitHub Action:
--set env.DB_URL="${{ secrets.DB_URL_PROD }}" \
--set env.DB_USERNAME="${{ secrets.DB_USERNAME_PROD }}" \
--set env.DB_PASSWORD="${{ secrets.DB_PASSWORD_PROD }}"
The application is configured to read these values as environment variables: properties
quarkus.datasource.jdbc.url=${DB_URL}
quarkus.datasource.username=${DB_USERNAME}
quarkus.datasource.password=${DB_PASSWORD}
Dockerfile Configuration:
The environment variables are set in the Dockerfile but left empty to be overridden at runtime: dockerfile
ENV DB_URL=""
ENV DB_USERNAME=""
ENV DB_PASSWORD=""
GitHub Action Workflow:
In the CI/CD pipeline, I’m using a local PostgreSQL database for testing. I recently updated the password, and it should now match correctly. The username also appears correct. I connected to azure and logged the variables to the console which are also correct. Local Development:
I was able to connect to this development database from my local machine using the same credentials without any issues.
Questions: What could cause this authentication failure, given that the same credentials work from local development? Could the issue lie with how the DB_URL is being interpreted in Kubernetes or Quarkus? Is there anything specific to Kubernetes, Helm, or Quarkus that might cause this kind of issue with environment variables or database connectivity?
Any insights or debugging tips would be greatly appreciated. Thanks in advance!
Turns out the password was cached. I had to delete and reupload all services and changes the password from the db.