Configuring Postgres 'Keycloak' Credentials
The Postgres keycloak credentials have to be changed with an SQL query directly done in the PostgreSQL instance connected with postgres-r00t-us3rn4m3 admin account
To Configure Postgres 'Keycloak' Credentials
-
With the tools of your choice, connect to the database with the
postgresuser at the JDBC URL:jdbc:postgresql://localhost:5432/postgres. -
Run the following SQL query:
ALTER ROLE keycloak WITH PASSWORD 'NEW_PASSWORD';
-
Only on the target machine, i.e. the machine that hosts the deployments script and the Docker file, open the script
deployment/docker/infra/postgres/start/10-create_user.shand edit the password in theCREATE USERquery.... echo "Creating database role: keycloak" ${POSTGRES} <<-EOSQL CREATE USER keycloak WITH CREATEDB PASSWORD 'NEW_PASSWORD'; EOSQLThis ensures the change survives to volume removing.
Note:Note that the script files must be executable. Run
chmod +xif needed. -
Change the password configuration in the microservices that need to connect to Postgres through this user (in this particular case it is
keycloak).-
Edit
deployment/docker/infra/docker-compose.ymland add theDB_PASSWORDenvironment variable.keycloak: ... environment: - DB_PASSWORD # Not specifying a value allow to transmit environment variable to the container. -
Edit the
.envfile located indocker-compose.ymlparent folder and add an environment variableDB_PASSWORDwith the password you have chosen. Note that you can also add the environment variable to the host machine.
-