We ran the below command to connect with the external Postgress DB.
export SCHEMA_NAME=<db_name>
export SCHEMA_USER=<db_user>
export SCHEMA_PWD=<db_user_password>
kubectl run -i --rm --tty percona-client --image=perconalab/percona- distribution-postgresql:14.2 -- restart=Never -- psql postgres://:< db_admin_password>@ -c "DROP DATABASE IF EXISTS ${SCHEMA_NAME};" -c "CREATE DATABASE ${SCHEMA_NAME} ENCODING='UTF8';" -c "DROP USER IF EXISTS ${SCHEMA_USER};" -c "CREATE USER ${SCHEMA_USER} WITH LOGIN CREATEDB CREATEROLE INHERIT REPLICATION CONNECTION LIMIT -1 PASSWORD '${SCHEMA_PWD}';" -c "GRANT ALL PRIVILEGES ON DATABASE ${SCHEMA_NAME} TO ${SCHEMA_USER};"
After completion we ran into this error (schema_user is a locally stored value which is not mentioned here for privacy):
ERROR: permission denied to create role
DETAIL: Only roles with the REPLICATION attribute may create roles with the REPLICATION attribute.
ERROR: role "{SCHEMA_USER}" does not exist
We brought up replication to our database team and got news that replication is not given out to user accounts in the database. Do we need the replication role for our database user to connect to the external database?
VIP Authentication Hub 2.2
The REPLICATION role was introduced anticipating additional functionality on the area of Database replication, but for now we're not using it in the product. It should be ok to not have this privilege.