Skip to content

Commit b31803b

Browse files
jmagakGitHub Actions
andauthored
RHDHBUGS-2625: Add procedure to configure Orchestrator to connect to existing PostgreSQL infrastructure (#2199)
* Add section how to disable SonataFlow references for Orchestrator plugins * Apply peer suggestions and fix gaps * Apply peer suggestions and fix gaps * Apply suggestions * Apply suggestions * Apply suggestions * Apply suggestions * Apply peer suggestions * Include Helm Chart deployments * Apply technical reviewers suggestions * Apply peer suggestions --------- Co-authored-by: GitHub Actions <github-actions@github.com>
1 parent 6361364 commit b31803b

9 files changed

Lines changed: 302 additions & 17 deletions

assemblies/extend_orchestrator-in-rhdh/assembly-install-rhdh-with-orchestrator-by-using-the-rhdh-helm-chart.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ include::../modules/extend_orchestrator-in-rhdh/proc-install-rhdh-on-ocp-with-th
1313

1414
include::../modules/extend_orchestrator-in-rhdh/proc-install-rhdh-using-helm-from-the-ocp-web-console.adoc[leveloffset=+1]
1515

16+
include::../modules/extend_orchestrator-in-rhdh/proc-configure-orchestrator-to-connect-to-existing-postgresql-infrastructure-using-helm.adoc[leveloffset=+1]
17+
1618
include::../modules/extend_orchestrator-in-rhdh/ref-resource-limits-for-installing-rhdh-with-the-orchestrator-plugin-when-using-helm.adoc[leveloffset=+1]
1719

1820
// manual installation

assemblies/extend_orchestrator-in-rhdh/assembly-install-rhdh-with-orchestrator-by-using-the-rhdh-operator.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ You can install {product} with Orchestrator by using the {product} Operator.
1111

1212
include::../modules/extend_orchestrator-in-rhdh/proc-enable-the-orchestrator-plugins-using-the-operator.adoc[leveloffset=+1]
1313

14+
include::../modules/extend_orchestrator-in-rhdh/proc-configure-orchestrator-to-connect-to-existing-postgresql-infrastructure.adoc[leveloffset=+1]
15+
1416
include::../modules/extend_orchestrator-in-rhdh/proc-upgrade-the-openshift-serverless-logic-operator-for-rhdh-1-9.adoc[leveloffset=+1]
1517

1618
include::../modules/extend_orchestrator-in-rhdh/proc-upgrade-the-orchestrator-plugins-for-1-9-operator-backed-instances.adoc[leveloffset=+1]

modules/configure_configuring-rhdh/proc-configure-an-external-postgresql-instance-using-the-helm-chart.adoc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
:_mod-docs-content-type: PROCEDURE
22

33
[id="configure-an-external-postgresql-instance-using-the-helm-chart_{context}"]
4-
= Configure an external PostgreSQL instance using the Helm Chart
4+
= Configure an external PostgreSQL instance using the Helm chart
55

66
[role="_abstract"]
7-
Configure an external PostgreSQL instance by using the Helm Chart instead of the default local PostgreSQL instance.
7+
Configure an external PostgreSQL instance by using the Helm chart instead of the default local PostgreSQL instance.
88

99
.Prerequisites
1010

@@ -15,7 +15,7 @@ Configure an external PostgreSQL instance by using the Helm Chart instead of the
1515
** `db_port`: Denotes your PostgreSQL instance port number, such as `5432`
1616
** `username`: Denotes the user name to connect to your PostgreSQL instance
1717
** `password`: Denotes the password to connect to your PostgreSQL instance
18-
* You have installed the {product-very-short} application by using the Helm Chart.
18+
* You have installed the {product-very-short} application by using the Helm chart.
1919
* 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.
2020

2121
[NOTE]
@@ -86,7 +86,8 @@ Where:
8686
`<db_host>`:: Your PostgreSQL instance DNS or IP address.
8787
`<ssl_mode>`:: Optional: For TLS connections, the required SSL mode.
8888
`<abs_path_to_pem_file>`:: Optional: For TLS connections, the absolute path to the Privacy-Enhanced Mail (PEM) file, for example `/opt/app-root/src/postgres-crt.pem`.
89-
89+
+
90+
include::../shared/snip-create-kubernetes-service-for-external-postgresql.adoc[]
9091
. Configure your PostgreSQL instance in the Helm configuration file named `values.yaml`:
9192
+
9293
[source,yaml,subs="+quotes,+attributes"]

modules/configure_configuring-rhdh/proc-configure-an-external-postgresql-instance-using-the-operator.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ Where:
8686
`<db_host>`:: Your PostgreSQL instance DNS or IP address.
8787
`<ssl_mode>`:: Optional: For TLS connections, the required SSL mode.
8888
`<abs_path_to_pem_file>`:: Optional: For TLS connections, the absolute path to the Privacy-Enhanced Mail (PEM) file, for example `/opt/app-root/src/postgres-crt.pem`.
89-
89+
+
90+
include::../shared/snip-create-kubernetes-service-for-external-postgresql.adoc[]
9091
. Optional: Ensure your external PostgreSQL instance is configured with recommended performance tuning parameters.
9192
+
9293
Set `shared_buffers` to approximately 1/4 and `effective_cache_size` to approximately 1/2 of the allocated database memory.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
:_mod-docs-content-type: PROCEDURE
2+
3+
[id="configure-orchestrator-to-connect-to-existing-postgresql-infrastructure-using-helm_{context}"]
4+
= Configure Orchestrator to connect to existing PostgreSQL infrastructure using Helm
5+
6+
[role="_abstract"]
7+
Connect the Orchestrator plugins to your existing PostgreSQL database when deploying with the Helm chart to leverage centralized database management and meet compliance requirements.
8+
9+
By default, when you enable the Orchestrator plugin by using the Helm chart with `orchestrator.enabled=true`, the chart automatically provisions a `SonataFlowPlatform` custom resource (CR) and creates the required PostgreSQL database resources. The chart uses the `orchestrator.sonataflowPlatform` values to configure these resources.
10+
11+
However, when you use an external PostgreSQL database that the Helm chart does not manage, you must explicitly configure the `orchestrator.sonataflowPlatform` values to reference your external database resources.
12+
13+
.Prerequisites
14+
* You have installed {product-very-short} by using the Helm chart.
15+
* You have {configuring-book-link}#configure-postgresql-instance-using-helm_configuring-external-postgresql-databases[configured {product-short} to use an external PostgreSQL database].
16+
* You have access to create jobs, secrets, services, and custom resources in the namespace where you deploy {product-very-short}.
17+
18+
.Procedure
19+
include::../shared/snip-create-orchestrator-database.adoc[]
20+
. Configure your external PostgreSQL database for Orchestrator in your Helm configuration file `values.yaml`:
21+
+
22+
[source,yaml,subs="+quotes,+attributes"]
23+
----
24+
orchestrator:
25+
enabled: true
26+
sonataflowPlatform:
27+
externalDBsecretRef: __<SECRET-NAME-WITH-DB-CREDENTIALS>__
28+
externalDBName: backstage_plugin_orchestrator
29+
externalDBHost: __<SERVICE-NAME-TO-DB>__
30+
externalDBPort: "5432"
31+
----
32+
+
33+
Where:
34+
35+
`orchestrator.enabled`:: Set to `true` to enable the Orchestrator plugin.
36+
`orchestrator.sonataflowPlatform.externalDBsecretRef`:: The secret name containing database credentials with `POSTGRES_USER`, `POSTGRES_PASSWORD`, `POSTGRES_HOST`, and `POSTGRES_PORT` keys.
37+
`orchestrator.sonataflowPlatform.externalDBName`:: The database name for Orchestrator data (must be `backstage_plugin_orchestrator`).
38+
`orchestrator.sonataflowPlatform.externalDBHost`:: The Kubernetes Service name pointing to your external database.
39+
`orchestrator.sonataflowPlatform.externalDBPort`:: The PostgreSQL port (typically `5432`).
40+
+
41+
[IMPORTANT]
42+
====
43+
Unlike the default configuration where the Helm chart automatically provisions database resources, this configuration explicitly references your external database Service and Secret. The `SonataFlowPlatform` CR will use these resources to connect to your external database instead of creating new database resources.
44+
====
45+
+
46+
. Apply the configuration changes in your Helm configuration file `values.yaml`:
47+
+
48+
[source,terminal,subs="+attributes"]
49+
----
50+
$ helm upgrade -n <your_namespace> <your_deploy_name> openshift-helm-charts/redhat-developer-hub -f values.yaml --version {product-chart-version}
51+
----
52+
53+
.Verification
54+
. Verify that the `SonataFlowPlatform` CR is running:
55+
+
56+
[source,terminal]
57+
----
58+
$ oc get sonataflowplatform sonataflow-platform -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}'
59+
True
60+
----
61+
+
62+
. In the {product-very-short} console, confirm that the Orchestrator frontend and backend features are available and can connect to your external database.
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
:_mod-docs-content-type: PROCEDURE
2+
3+
[id="configure-orchestrator-to-connect-to-existing-postgresql-infrastructure_{context}"]
4+
= Configure Orchestrator to connect to existing PostgreSQL infrastructure
5+
6+
[role="_abstract"]
7+
Connect the Orchestrator plugins to your existing PostgreSQL database to leverage centralized database management and meet compliance requirements.
8+
9+
By default, when you enable the Orchestrator plugin by using the Operator, the `dependencies: - ref: sonataflow` field automatically provisions a `SonataFlowPlatform` custom resource (CR) and creates the required PostgreSQL database resources. The Operator uses specific naming patterns for these resources (such as `backstage-psql-{{backstage-name}}` for the service and `backstage-psql-secret-{{backstage-name}}` for the secret).
10+
11+
However, when you use an external PostgreSQL database that the Operator does not manage, these default resources and naming patterns do not exist. You must explicitly configure the `SonataFlowPlatform` CR to reference your external database resources and remove the automatic dependency provisioning.
12+
13+
.Prerequisites
14+
* You have installed {product-very-short} by using the Operator.
15+
* You have {configuring-book-link}#configure-external-postgresql-databases_configuring-rhdh[configured {product-short} to use an external PostgreSQL database].
16+
* You have access to create jobs, secrets, config maps, and custom resources in the namespace where you deploy the {product-custom-resource-type} CR.
17+
18+
.Procedure
19+
include::../shared/snip-create-orchestrator-database.adoc[]
20+
. Create a `SonataFlowPlatform` CR that references your external PostgreSQL service:
21+
+
22+
[source,yaml,subs="+attributes,+quotes"]
23+
----
24+
apiVersion: sonataflow.org/v1alpha08
25+
kind: SonataFlowPlatform
26+
metadata:
27+
name: sonataflow-platform
28+
spec:
29+
monitoring:
30+
enabled: true
31+
services:
32+
dataIndex:
33+
enabled: true
34+
persistence:
35+
postgresql:
36+
secretRef:
37+
name: __<SECRET-NAME-WITH-DB-CREDENTIALS>__
38+
userKey: POSTGRES_USER
39+
passwordKey: POSTGRES_PASSWORD
40+
serviceRef:
41+
name: __<SERVICE-NAME-TO-DB>__
42+
namespace: __<{product-very-short}-NAMESPACE>__
43+
databaseName: backstage_plugin_orchestrator
44+
jobService:
45+
enabled: true
46+
persistence:
47+
postgresql:
48+
secretRef:
49+
name: __<SECRET-NAME-WITH-DB-CREDENTIALS>__
50+
userKey: POSTGRES_USER
51+
passwordKey: POSTGRES_PASSWORD
52+
serviceRef:
53+
name: __<SERVICE-NAME-TO-DB>__
54+
namespace: __<{product-very-short}-NAMESPACE>__
55+
databaseName: backstage_plugin_orchestrator
56+
----
57+
+
58+
[IMPORTANT]
59+
====
60+
Unlike the default configuration that uses the `dependencies: - ref: sonataflow` field to automatically provision database resources with specific naming patterns, this configuration explicitly references your external database Service and Secret. The `SonataFlowPlatform` CR will use these resources to connect to your external database instead of creating new database resources.
61+
====
62+
+
63+
. Configure the Orchestrator plugins in your dynamic plugins config map to remove the default `sonataflow` dependency and explicitly reference the SonataFlowPlatform services:
64+
+
65+
[source,yaml,subs="+attributes,+quotes"]
66+
----
67+
apiVersion: v1
68+
kind: ConfigMap
69+
metadata:
70+
name: orchestrator-plugin
71+
data:
72+
dynamic-plugins.yaml: |
73+
includes:
74+
- dynamic-plugins.default.yaml
75+
plugins:
76+
# Orchestrator plugins
77+
- package: "oci://registry.access.redhat.com/rhdh/red-hat-developer-hub-backstage-plugin-orchestrator:{{inherit}}"
78+
disabled: false
79+
- package: "oci://registry.access.redhat.com/rhdh/red-hat-developer-hub-backstage-plugin-orchestrator-backend:{{inherit}}"
80+
disabled: false
81+
pluginConfig:
82+
orchestrator:
83+
dataIndexService:
84+
url: http://__<SERVICE-NAME-SONATAFLOW-PLATFORM-DATA-INDEX>__
85+
dependencies: [{}] # Empty array removes default 'ref: sonataflow' to prevent automatic database provisioning
86+
- package: "oci://registry.access.redhat.com/rhdh/red-hat-developer-hub-backstage-plugin-scaffolder-backend-module-orchestrator:{{inherit}}"
87+
disabled: false
88+
pluginConfig:
89+
orchestrator:
90+
dataIndexService:
91+
url: http://__<SERVICE-NAME-SONATAFLOW-PLATFORM-DATA-INDEX>__
92+
dependencies: [{}] # Empty array removes default 'ref: sonataflow' to prevent automatic database provisioning
93+
- package: "oci://registry.access.redhat.com/rhdh/red-hat-developer-hub-backstage-plugin-orchestrator-form-widgets:{{inherit}}"
94+
disabled: false
95+
----
96+
+
97+
. Update your {product-custom-resource-type} CR to reference the orchestrator plugin config map and inject the database credentials secret:
98+
+
99+
[source,yaml,subs="+attributes,+quotes"]
100+
----
101+
apiVersion: rhdh.redhat.com/v1alpha5
102+
kind: {product-custom-resource-type}
103+
metadata:
104+
name: orchestrator
105+
spec:
106+
application:
107+
appConfig:
108+
configMaps:
109+
- name: app-config-rhdh
110+
dynamicPluginsConfigMapName: orchestrator-plugin
111+
extraEnvs:
112+
secrets:
113+
- name: __<SECRET-NAME-WITH-DB-CREDENTIALS>__
114+
----
115+
116+
.Verification
117+
. Verify that the `SonataFlowPlatform` CR is running:
118+
+
119+
[source,terminal]
120+
----
121+
$ oc get sonataflowplatform sonataflow-platform -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}'
122+
True
123+
----
124+
+
125+
. In the {product-very-short} console, confirm that the Orchestrator frontend and backend features are available and can connect to your external database.

modules/extend_orchestrator-in-rhdh/proc-install-rhdh-on-ocp-with-the-orchestrator-using-the-helm-cli.adoc

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,11 @@ $ helm install <release_name> openshift-helm-charts/redhat-developer-hub \
7171
--set orchestrator.serverlessLogicOperator=false
7272
----
7373

74-
. (Optional) If you are using an external database, add the following configuration under `orchestrator.sonataflowPlatform` in your `values.yaml` file:
75-
+
76-
[source,yaml]
77-
----
78-
orchestrator:
79-
sonataflowPlatform:
80-
externalDBsecretRef: "<cred-secret>"
81-
externalDBName: "<database_name>" # The name of the user-configured existing database (Not the database that the orchestrator and sonataflow resources use).
82-
externalDBHost: "<database_host>"
83-
externalDBPort: "<database_port>"
84-
----
74+
. (Optional) To configure Orchestrator to use an external PostgreSQL database, follow the detailed instructions in xref:configure-orchestrator-to-connect-to-existing-postgresql-infrastructure-using-helm_{context}[Configure Orchestrator to connect to existing PostgreSQL infrastructure using Helm].
8575
+
8676
[NOTE]
8777
====
88-
This step only configures the Orchestrators use of an external database. To configure {product} to use an external PostgreSQL instance, follow the steps in {configuring-book-link}#configure-postgresql-instance-using-helm_configuring-external-postgresql-databases[Configure a PostgreSQL instance using Helm].
78+
Configuring an external database for Orchestrator requires additional steps beyond standard {product-very-short} external database configuration. You must create the `backstage_plugin_orchestrator` database, configure the `orchestrator.sonataflowPlatform` values, and ensure proper service connectivity. See the detailed procedure for complete instructions.
8979
====
9080

9181
.Verification
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
:_mod-docs-content-type: SNIPPET
2+
. Create a Kubernetes service that points to your external PostgreSQL database:
3+
+
4+
[source,yaml,subs="+attributes,+quotes"]
5+
----
6+
apiVersion: v1
7+
kind: Service
8+
metadata:
9+
name: external-postgresql-service
10+
spec:
11+
type: ExternalName
12+
externalName: __<your-external-db-host-name>__
13+
ports:
14+
- port: 5432
15+
targetPort: 5432
16+
protocol: TCP
17+
----
18+
+
19+
Where:
20+
21+
`external-postgresql-service`:: Name of the service to reference in plugin configurations.
22+
`ExternalName`:: Service type that creates a CNAME record to the external database host name.
23+
`__<your-external-db-host-name>__`:: FQDN of your external PostgreSQL server, for example, `postgres.example.com`.
24+
+
25+
[NOTE]
26+
====
27+
If your external database is outside the cluster or uses an IP address instead of a host name, create a service with endpoints:
28+
29+
[source,yaml,subs="+attributes,+quotes"]
30+
----
31+
apiVersion: v1
32+
kind: Service
33+
metadata:
34+
name: external-postgresql-service
35+
spec:
36+
ports:
37+
- port: 5432
38+
targetPort: 5432
39+
protocol: TCP
40+
---
41+
apiVersion: v1
42+
kind: Endpoints
43+
metadata:
44+
name: external-postgresql-service
45+
subsets:
46+
- addresses:
47+
- ip: __<your-external-db-ip>__
48+
ports:
49+
- port: 5432
50+
protocol: TCP
51+
----
52+
53+
Where:
54+
55+
`__<your-external-db-ip>__`:: IP address of your external PostgreSQL server.
56+
====
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
:_mod-docs-content-type: SNIPPET
2+
. Create the `backstage_plugin_orchestrator` database on your external PostgreSQL server by applying the following job:
3+
+
4+
[source,yaml,subs="+attributes,+quotes"]
5+
----
6+
apiVersion: batch/v1
7+
kind: Job
8+
metadata:
9+
name: create-sonataflow-database-developer-hub
10+
spec:
11+
ttlSecondsAfterFinished: 30
12+
activeDeadlineSeconds: 120
13+
template:
14+
spec:
15+
containers:
16+
- name: psql
17+
image: quay.io/fedora/postgresql-15:latest
18+
resources:
19+
limits:
20+
cpu: "100m"
21+
memory: "128Mi"
22+
requests:
23+
cpu: "100m"
24+
memory: "64Mi"
25+
securityContext:
26+
readOnlyRootFilesystem: true
27+
allowPrivilegeEscalation: false
28+
runAsNonRoot: true
29+
capabilities:
30+
drop:
31+
- ALL
32+
envFrom:
33+
- secretRef:
34+
name: __<SECRET-NAME-WITH-DB-CREDENTIALS>__
35+
command: [ "sh", "-c" ]
36+
args:
37+
- |
38+
set -e
39+
# Check if the backstage_plugin_orchestrator database exists
40+
DB_EXISTS=$(PGPASSWORD=${POSTGRES_PASSWORD} psql -h ${POSTGRES_HOST} -p ${POSTGRES_PORT} -U ${POSTGRES_USER} -tAc "SELECT 1 FROM pg_database WHERE datname='backstage_plugin_orchestrator'" postgres)
41+
if [ -z "$DB_EXISTS" ]; then
42+
# Create the database if it does not exist
43+
PGPASSWORD=${POSTGRES_PASSWORD} psql -h ${POSTGRES_HOST} -p ${POSTGRES_PORT} -U ${POSTGRES_USER} -c "CREATE DATABASE backstage_plugin_orchestrator;" postgres
44+
fi
45+
restartPolicy: Never
46+
----

0 commit comments

Comments
 (0)