6.4. Use external PostgreSQL database#
This section describes, how you can use an external PostgreSQL database management system for all services. Use this configuration, if you have a PostgreSQL database cluster already in place, with redundancy and failover mechanisms.
Important
You need to ensure that your PostgreSQL database is at least version 12.
6.4.1. Prepare external PostgreSQL database#
Before you can use an external PostgreSQL database, you need to prepare it properly.
Create a PostgreSQL user for each of the following services:
Guardian
Keycloak
Keycloak Extensions
Notifications API
Self Service
UMC Session
Create a database for each of the services listed in the preceding step. Nubus uses the following default database names.
guardiankeycloakkeycloak_extensionsnotificationsapiselfserviceumcsession
If you want to define custom database names, see Define custom database names.
Important
You need to follow the lexical structure for identifiers and keywords for PostgreSQL database names. Otherwise, the database setup fails, which has subsequent consequences for the Nubus deployment. Database names are identifiers. See Identifiers and Key Words in PostgreSQL 15.8 Documentation [4].
6.4.2. Configure external PostgreSQL database#
To configure an external PostgreSQL database,
you need to provide the connection details in the Helm Chart configuration in your
custom_values.yaml values file
as outlined in Listing 6.6.
Add the connection parameters for your external PostgreSQL database as shown in Listing 6.6 to your
custom_values.yamlvalues file.global.postgresql.connection.hostThe hostname of the external PostgreSQL database management system.
global.postgresql.connection.portThe port number of the external PostgreSQL database management system.
keycloak.postgresql.auth.databaseThe database name for the Keycloak.
nubusGuardian.postgresql.auth.databaseThe database name for the Guardian.
nubusKeycloakExtensions.postgresql.auth.databaseThe database name for the Keycloak Extensions.
nubusNotificationsApi.postgresql.auth.databaseThe database name for the Notifications API.
nubusUmcServer.postgresql.authSession.auth.databaseThe database name for the UMC session.
nubusStackDataUms.nubusUmcServer.postgresql.auth.databaseThe database name for the Self Service.
global: postgresql: connection: host: "postgres.db.example.com" port: 5432 postgresql: enabled: false keycloak: postgresql: auth: database: "<keycloak-database>" nubusGuardian: postgresql: auth: database: "<guardian-database>" nubusKeycloakExtensions: postgresql: auth: database: "<keycloak-extensions-database>" nubusNotificationsApi: postgresql: auth: database: "<notificationsapi-database>" nubusUmcServer: postgresql: authSession: auth: database: "<umcsession-database>" nubusStackDataUms: nubusUmcServer: postgresql: auth: database: "<selfservice-database>"
Add the credentials for each of the PostgreSQL users you created in Prepare external PostgreSQL database.
- Custom credential configuration
Add the content from Listing 6.7 to your
custom_values.yamlvalues file. The listing uses the following Helm Chart values:keycloak: postgresql: auth: username: "<keycloak-user>" password: "<keycloak-password>" nubusGuardian: postgresql: auth: username: "<guardian-user>" password: "<guardian-password>" nubusKeycloakExtensions: postgresql: auth: username: "<keycloak-extensions-user>" password: "<keycloak-extensions-password>" nubusNotificationsApi: postgresql: auth: username: "<notifications-api-user>" password: "<notifications-api-password>" nubusUmcServer: postgresql: selfservice: auth: password: "<selfservice-password>" authSession: auth: username: "<umcsession-user>" password: "<umcsession-password>" nubusStackDataUms: nubusUmcServer: postgresql: auth: username: "<selfservice-user>"
- Kubernetes secrets for credentials configuration
Use the example in Listing 6.8 if you want to use existing Kubernetes Secrets. The listing uses the following Helm Chart values:
nubusGuardian.postgresql.auth.existingSecret.keyMapping.passwordnubusKeycloakExtensions.postgresql.auth.existingSecret.keyMapping.passwordnubusNotificationsApi.postgresql.auth.existingSecret.keyMapping.passwordnubusUmcServer.postgresql.selfservice.auth.existingSecret.namenubusUmcServer.postgresql.selfservice.auth.existingSecret.keyMapping.passwordnubusUmcServer.postgresql.authSession.auth.existingSecret.namenubusUmcServer.postgresql.authSession.auth.existingSecret.keyMapping.password
Listing 6.8 Use existing Kubernetes Secrets for PostgreSQL user credentials for external PostgreSQL database#keycloak: postgresql: auth: username: "<keycloak-user>" existingSecret: name: "<keycloak-secret-name>" keyMapping: password: "<keycloak-password-key>" nubusGuardian: postgresql: auth: username: "<guardian-user>" existingSecret: name: "<guardian-secret-name>" keyMapping: password: "<guardian-password-key>" nubusKeycloakExtensions: postgresql: auth: username: "<keycloak-extensions-user>" existingSecret: name: "<keycloak-extensions-secret-name>" keyMapping: password: "<keycloak-extensions-password-key>" nubusNotificationsApi: postgresql: auth: username: "<notifications-api-user>" existingSecret: name: "<notifications-api-secret-name>" keyMapping: password: "<notifications-api-secret-password-key>" nubusUmcServer: postgresql: selfservice: auth: existingSecret: name: "<selfservice-secret-name>" keyMapping: password: "<selfservice-password-key>" authSession: auth: username: "<umcsession-user>" existingSecret: name: "<umcsession-secret-name>" keyMapping: password: "<umcsession-password-key>" nubusStackDataUms: nubusUmcServer: postgresql: auth: username: "<selfservice-user>"
6.4.3. Define custom database names#
To define custom database names,
add the content from Listing 6.9 to your custom_values.yaml.
Replace custom_name_for_* with your respective values for the database name.
nubusGuardian:
postgresql:
auth:
database: "custom_name_for_guardian"
keycloak:
postgresql:
auth:
database: "custom_name_for_keycloak"
nubusKeycloakExtensions:
postgresql:
auth:
database: "custom_name_for_keycloak_extensions"
nubusNotificationsApi:
postgresql:
auth:
database: "custom_name_for_notifications_api"
nubusUmcServer:
postgresql:
selfservice:
auth:
database: "custom_name_for_selfservice"
authSession:
auth:
database: "custom_name_for_umcsession"
Tip
To lookup the database names in your cluster:
Render the Helm Chart template as described in Render Helm Chart template.
Look for the ConfigMap with
metadata.name: "release-name-postgresql-provisioning".You find the list of database names in the ConfigMap
data.databases.list.