I'm doing the ch02s07 lab, but can't get my todo-list app to connect to the DB.
Pod logs: Could not connect to database:error: password authentication failed for user "developer"
When I check my posgres pod (created from the postgres (ephemeral) template), I dont see the todo_list db.
Anyone see what I'm doing wrong?
OK... what worked for me... editing the DeploymentConfig Environment Variables.
POSTGRESQL_USER, POSTGRESQL_PASSWORD, POSTGRESQL_DATABASE were created as secrets. (the Secrets seem to match default values, so for example "sampledb" instead of "todo_list").
After manually setting values to :
POSTGRESQL_USER = developer
POSTGRESQL_PASSWORD = developer (not "test" -- found correct password here: https://github.com/RedHatTraining/DO288-apps/blob/main/apps/deploy-review/todo-list/db.js)
POSTGRESQL_DATABASE = todo_list
things seem to start work.
Hope it helps someone facing this error.
But would be interested to also hear if I was the only one seeing this. (that means I'm doing something incorrect)
OK... what worked for me... editing the DeploymentConfig Environment Variables.
POSTGRESQL_USER, POSTGRESQL_PASSWORD, POSTGRESQL_DATABASE were created as secrets. (the Secrets seem to match default values, so for example "sampledb" instead of "todo_list").
After manually setting values to :
POSTGRESQL_USER = developer
POSTGRESQL_PASSWORD = developer (not "test" -- found correct password here: https://github.com/RedHatTraining/DO288-apps/blob/main/apps/deploy-review/todo-list/db.js)
POSTGRESQL_DATABASE = todo_list
things seem to start work.
Hope it helps someone facing this error.
But would be interested to also hear if I was the only one seeing this. (that means I'm doing something incorrect)
I had a similar query for DB_PASSWORD variable in the exercise. Your observation is partially correct. The application has to connect using the username and password provided in database. However in the application if no username password is specified it takes the default mentioned in code -
const { Client } = require("pg"); const host = process.env.DB_HOST || "postgresql"; const user = process.env.DB_USER || "developer"; const password = process.env.DB_PASSWORD || "developer"; const database = "todo_list"; const client = new Client({ host, user, database, password });
While starting the application, providing the DB_PASSWORD variable with value test makes it connect with DB and the pod is created. So the correct method to solve this would be to use the test password in the application to connect to DB.
Out of interest, does that mean you managed to get Postgres (Ephemeral) deployed (with the custom parameters for the username, password, dbname) using the instructions from the lab solution?
Yes using the details provided in the lab:
Database Service Name: postgresql
PostgreSQL Connection Username: developer
PostgreSQL Connection Password: test
PostgreSQL Database Name: todo_list
Application Name: todo-list
Application Image: registry.ocp4.example.com:8443/redhattraining/openshift-dev-deploy-review-todo-list
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.