You can configure an external PostgreSQL instance using the {product} Operator. By default, the Operator creates and manages a local instance of PostgreSQL in the same namespace where you have deployed the {product-very-short} instance. However, you can change this default setting to configure an external PostgreSQL database server, for example, Amazon Web Services (AWS) Relational Database Service (RDS) or Azure database.
-
You meet the {about-book-link}#rhdh-sizing_about-rhdh[Sizing requirements for external PostgreSQL deployments].
-
You are using a supported version of PostgreSQL. For more information, see the Product life cycle page.
-
You have the following details:
-
db-host: Denotes your PostgreSQL instance Domain Name System (DNS) or IP address -
db-port: Denotes your PostgreSQL instance port number, such as5432 -
username: Denotes the user name to connect to your PostgreSQL instance -
password: Denotes the password to connect to your PostgreSQL instance
-
-
You have installed the {product} Operator.
-
Optional: You have a CA certificate, Transport Layer Security (TLS) private key, and TLS certificate so that you can secure your database connection by using the TLS protocol. For more information, refer to your PostgreSQL vendor documentation.
|
Note
|
By default, {product-short} uses a database for each plugin and automatically creates it if none is found. You might need the |
-
Optional: Create a certificate secret to configure your PostgreSQL instance with a TLS connection:
$ cat <<EOF | oc -n {my-product-namespace} create -f - apiVersion: v1 kind: Secret metadata: name: {my-product-database-certificates-secrets} (1) type: Opaque stringData: postgres-ca.pem: |- -----BEGIN CERTIFICATE----- <ca-certificate-key> (2) postgres-key.key: |- -----BEGIN CERTIFICATE----- <tls-private-key> (3) postgres-crt.pem: |- -----BEGIN CERTIFICATE----- <tls-certificate-key> (4) # ... EOF-
Provide the name of the certificate secret.
-
Provide the CA certificate key.
-
Optional: Provide the TLS private key.
-
Optional: Provide the TLS certificate key.
-
-
Create a credential secret to connect with the PostgreSQL instance:
$ cat <<EOF | oc -n {my-product-namespace} create -f - apiVersion: v1 kind: Secret metadata: name: {my-product-database-secrets} (1) type: Opaque stringData: (2) POSTGRES_PASSWORD: <password> POSTGRES_PORT: "<db-port>" POSTGRES_USER: <username> POSTGRES_HOST: <db-host> PGSSLMODE: <ssl-mode> # for TLS connection (3) NODE_EXTRA_CA_CERTS: <abs-path-to-pem-file> # for TLS connection, e.g. /opt/app-root/src/postgres-crt.pem (4) EOF-
Provide the name of the credential secret.
-
Provide credential data to connect with your PostgreSQL instance.
-
Optional: Provide the value based on the required Secure Sockets Layer (SSL) mode.
-
Optional: Provide the value only if you need a TLS connection for your PostgreSQL instance.
-
-
Optional: Ensure your external PostgreSQL instance is configured with recommended performance tuning parameters.
Set
shared_buffersto approximately 1/4 andeffective_cache_sizeto approximately 1/2 of the allocated database memory. -
Create your
{product-custom-resource-type}custom resource (CR):cat <<EOF | oc -n {my-product-namespace} create -f - apiVersion: rhdh.redhat.com/v1alpha3 kind: Backstage metadata: name: <backstage-instance-name> spec: database: enableLocalDb: false (1) application: extraFiles: mountPath: <path> # e g /opt/app-root/src secrets: - name: {my-product-database-certificates-secrets} (2) key: postgres-crt.pem, postgres-ca.pem, postgres-key.key # key name as in {my-product-database-certificates-secrets} Secret extraEnvs: secrets: - name: {my-product-database-secrets} (3) # ...-
Set the value of the
enableLocalDbparameter tofalseto disable creating local PostgreSQL instances. -
Provide the name of the certificate secret if you have configured a TLS connection.
-
Provide the name of the credential secret that you created.
NoteThe environment variables listed in the
BackstageCR work with the Operator default configuration. If you have changed the Operator default configuration, you must reconfigure theBackstageCR accordingly.
-
-
Apply the
{product-custom-resource-type}CR to the namespace where you have deployed the {product-short} instance.