Search code examples
openshiftkeycloak

How to connect RedHat SSO to external postgres database using OpenShift 4.x?


Anyone having any idea on how to connect RHSSO template or operator in OpenShift with external postgres database. We are using Azure managed Postgresql DB 14.

Template installation are only for ephemeral and postgres persistent db which i tried but had no luck connecting with external db.

I am already running container based keycloak community version with external database connection and want to establish with RHSSO.

Thank you for your time.


Solution

  • You can use Red Hat Single Sign-On Operator from OperatorHub. We have to terminate internal RedHat sso database connection and connect to external database.

    1. Create a Keycloak instance from this Operator, make sure to enable external database checkbox.
    2. Create a secret adding necessary environment variables with external database credentials and add keycloak instance as your workload to this secret
    3. Terminate your keycloak pod for reflecting latest secret file values in it.

    YAML file:

    apiVersion: v1
    kind: Secret
    metadata:
      name: keycloak-db-secret
      namespace: <your_namespace>
    type: Opaque
    stringData:
      POSTGRES_DATABASE: DB_Name
      POSTGRES_EXTERNAL_ADDRESS: value
      POSTGRES_EXTERNAL_PORT: 5432
      POSTGRES_HOST: <IP of db>
      POSTGRES_PASSWORD: value
      POSTGRES_USERNAME: value
      POSTGRES_SUPERUSER: true