From 1b0738ffdcdf2133c8f6e479bf38a1107fafca24 Mon Sep 17 00:00:00 2001 From: Elai Shalev Date: Thu, 19 Jun 2025 15:01:11 +0300 Subject: [PATCH 1/6] Backstage chart: fixing RHIDP/7806 in Orchestrator's SFP config --- charts/backstage/README.md | 11 +++- charts/backstage/README.md.gotmpl | 9 ++- charts/backstage/templates/sonataflows.yaml | 71 ++++++++++++++------- charts/backstage/values.schema.json | 10 +++ charts/backstage/values.schema.tmpl.json | 10 +++ charts/backstage/values.yaml | 6 ++ 6 files changed, 91 insertions(+), 26 deletions(-) diff --git a/charts/backstage/README.md b/charts/backstage/README.md index cb3468f3..4bbaa5bc 100644 --- a/charts/backstage/README.md +++ b/charts/backstage/README.md @@ -187,7 +187,9 @@ Kubernetes: `>= 1.27.0-0` | orchestrator.sonataflowPlatform.createDBJobImage | Image for the container used by the create-db job | string | `"{{ .Values.upstream.postgresql.image.registry }}/{{ .Values.upstream.postgresql.image.repository }}:{{ .Values.upstream.postgresql.image.tag }}"` | | orchestrator.sonataflowPlatform.eventing.broker.name | | string | `""` | | orchestrator.sonataflowPlatform.eventing.broker.namespace | | string | `""` | +| orchestrator.sonataflowPlatform.externalDBHost | Host for the user-configured external Database | string | `""` | | orchestrator.sonataflowPlatform.externalDBName | Name for the user-configured external Database | string | `""` | +| orchestrator.sonataflowPlatform.externalDBPort | Port for the user-configured external Database | string | `""` | | orchestrator.sonataflowPlatform.externalDBsecretRef | Secret name for the user-created secret to connect an external DB | string | `""` | | orchestrator.sonataflowPlatform.initContainerImage | Image for the init container used by the create-db job | string | `"{{ .Values.upstream.postgresql.image.registry }}/{{ .Values.upstream.postgresql.image.repository }}:{{ .Values.upstream.postgresql.image.tag }}"` | | orchestrator.sonataflowPlatform.monitoring.enabled | | bool | `true` | @@ -373,13 +375,20 @@ and populate the following values in the values.yaml: ```bash externalDBsecretRef: externalDBName: "" + externalDBHost: "" + externalDBPort: "" ``` +The values for externalDBHost and externalDBPort should match the ones configured in the cred-secret. + Please note that `externalDBName` is the name of the user-configured existing database, not the database that the orchestrator and sonataflow resources will use. +A Job will run to create the 'sonataflow' databse in the external database for the workflows to use. Finally, install the Helm Chart (including [setting up the external DB](https://github.com/redhat-developer/rhdh-chart/blob/main/docs/external-db.md)): ``` helm install redhat-developer/backstage \ --set orchestrator.enabled=true \ --set orchestrator.sonataflowPlatform.externalDBsecretRef= \ - --set orchestrator.sonataflowPlatform.externalDBName=example + --set orchestrator.sonataflowPlatform.externalDBName=example \ + --set orchestrator.sonataflowPlatform.externalDBHost=example \ + --set orchestrator.sonataflowPlatform.externalDBPort=example ``` \ No newline at end of file diff --git a/charts/backstage/README.md.gotmpl b/charts/backstage/README.md.gotmpl index 16f2a827..3dbd195d 100644 --- a/charts/backstage/README.md.gotmpl +++ b/charts/backstage/README.md.gotmpl @@ -310,13 +310,20 @@ and populate the following values in the values.yaml: ```bash externalDBsecretRef: externalDBName: "" + externalDBHost: "" + externalDBPort: "" ``` +The values for externalDBHost and externalDBPort should match the ones configured in the cred-secret. + Please note that `externalDBName` is the name of the user-configured existing database, not the database that the orchestrator and sonataflow resources will use. +A Job will run to create the 'sonataflow' databse in the external database for the workflows to use. Finally, install the Helm Chart (including [setting up the external DB](https://github.com/redhat-developer/rhdh-chart/blob/main/docs/external-db.md)): ``` helm install redhat-developer/backstage \ --set orchestrator.enabled=true \ --set orchestrator.sonataflowPlatform.externalDBsecretRef= \ - --set orchestrator.sonataflowPlatform.externalDBName=example + --set orchestrator.sonataflowPlatform.externalDBName=example \ + --set orchestrator.sonataflowPlatform.externalDBHost=example \ + --set orchestrator.sonataflowPlatform.externalDBPort=example ``` \ No newline at end of file diff --git a/charts/backstage/templates/sonataflows.yaml b/charts/backstage/templates/sonataflows.yaml index d005c447..182e2681 100644 --- a/charts/backstage/templates/sonataflows.yaml +++ b/charts/backstage/templates/sonataflows.yaml @@ -35,7 +35,7 @@ spec: enabled: true persistence: postgresql: - {{- if .Values.upstream.postgresql.enabled }} +{{- if .Values.upstream.postgresql.enabled }} secretRef: name: {{ .Release.Name }}-postgresql-svcbind-postgres userKey: username @@ -44,23 +44,23 @@ spec: name: {{ .Release.Name }}-postgresql namespace: {{ .Release.Namespace }} databaseName: sonataflow - {{- else }} +{{- else }} secretRef: name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef }} userKey: POSTGRES_USER passwordKey: POSTGRES_PASSWORD - jdbcUrl: jdbc:postgresql://{{ .Values.upstream.backstage.appConfig.backend.database.connection.host}}:{{ .Values.upstream.backstage.appConfig.backend.database.connection.port}}/sonataflow?currentSchema=data-index-service - {{- end }} - {{- if .Values.orchestrator.sonataflowPlatform.dataIndexImage }} + jdbcUrl: jdbc:postgresql://{{ .Values.orchestrator.sonataflowPlatform.externalDBHost }}:{{ .Values.orchestrator.sonataflowPlatform.externalDBPort }}/{{ .Values.orchestrator.sonataflowPlatform.externalDBName }}?currentSchema=data-index-service +{{- end }} +{{- if .Values.orchestrator.sonataflowPlatform.dataIndexImage }} podTemplate: container: image: {{ .Values.orchestrator.sonataflowPlatform.dataIndexImage }} - {{- end }} +{{- end }} jobService: enabled: true persistence: postgresql: - {{- if .Values.upstream.postgresql.enabled }} +{{- if .Values.upstream.postgresql.enabled }} secretRef: name: {{ .Release.Name }}-postgresql-svcbind-postgres userKey: username @@ -69,18 +69,18 @@ spec: name: {{ .Release.Name }}-postgresql namespace: {{ .Release.Namespace }} databaseName: sonataflow - {{- else }} +{{- else }} secretRef: name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef}} userKey: POSTGRES_USER passwordKey: POSTGRES_PASSWORD - jdbcUrl: jdbc:postgresql://{{ .Values.upstream.backstage.appConfig.backend.database.connection.host}}:{{ .Values.upstream.backstage.appConfig.backend.database.connection.port}}/sonataflow?currentSchema=jobs-service - {{- end }} - {{- if .Values.orchestrator.sonataflowPlatform.jobServiceImage }} + jdbcUrl: jdbc:postgresql://{{ .Values.orchestrator.sonataflowPlatform.externalDBHost }}:{{ .Values.orchestrator.sonataflowPlatform.externalDBPort }}/{{ .Values.orchestrator.sonataflowPlatform.externalDBName }}?currentSchema=jobs-service +{{- end }} +{{- if .Values.orchestrator.sonataflowPlatform.jobServiceImage }} podTemplate: container: image: {{ .Values.orchestrator.sonataflowPlatform.jobServiceImage }} - {{- end }} +{{- end }} --- apiVersion: batch/v1 kind: Job @@ -88,6 +88,7 @@ metadata: name: {{ .Release.Name }}-create-sonataflow-database namespace: {{ .Release.Namespace }} spec: + activeDeadlineSeconds: 120 template: spec: initContainers: @@ -111,17 +112,30 @@ spec: - bash - -c - | - {{- if .Values.upstream.postgresql.enabled }} +{{- if .Values.upstream.postgresql.enabled }} dbHost="{{ .Release.Name }}-postgresql" dbPort="5432" - {{- else }} - dbHost="{{ .Values.upstream.backstage.appConfig.backend.database.connection.host }}" - dbPort="{{ .Values.upstream.backstage.appConfig.backend.database.connection.port }}" - {{- end }} - until timeout --preserve-status --kill-after=3 2 bash -c ">/dev/tcp/${dbHost}/${dbPort}"; do +{{- else }} + dbHost=${POSTGRES_HOST} + dbPort=${POSTGRES_PORT} +{{- end }} + until timeout 2 bash -c ">/dev/tcp/$dbHost/$dbPort"; do echo 'Waiting for DB...' sleep 2 done +{{- if not .Values.upstream.postgresql.enabled }} + env: + - name: POSTGRES_HOST + valueFrom: + secretKeyRef: + name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef}} + key: POSTGRES_HOST + - name: POSTGRES_PORT + valueFrom: + secretKeyRef: + name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef}} + key: POSTGRES_PORT +{{- end }} containers: - name: psql image: "{{- tpl .Values.orchestrator.sonataflowPlatform.createDBJobImage . -}}" @@ -140,22 +154,31 @@ spec: drop: - ALL env: +{{- if .Values.upstream.postgresql.enabled }} - name: PGPASSWORD valueFrom: -{{- if .Values.upstream.postgresql.enabled }} secretKeyRef: name: {{ .Release.Name }}-postgresql-svcbind-postgres key: password +{{- else }} + - name: POSTGRES_HOST + valueFrom: + secretKeyRef: + name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef}} + key: POSTGRES_HOST + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef}} + key: POSTGRES_USER +{{- end }} command: [ "sh", "-c" ] +{{- if .Values.upstream.postgresql.enabled }} args: - "psql -h {{ .Release.Name }}-postgresql -U postgres -c 'CREATE DATABASE sonataflow;' || echo WARNING: Could not create database" {{- else }} - secretKeyRef: - name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef}} - key: POSTGRES_PASSWORD - command: [ "sh", "-c" ] args: - - "psql -h {{ .Values.upstream.backstage.appConfig.backend.database.connection.host }} -U {{ .Values.upstream.backstage.appConfig.backend.database.connection.user }} -d {{ .Values.orchestrator.sonataflowPlatform.externalDBName }} -c 'CREATE DATABASE sonataflow;' || echo WARNING: Could not create database" + - "psql -h ${POSTGRES_HOST} -U ${POSTGRES_USER} -d {{ .Values.orchestrator.sonataflowPlatform.externalDBName }} -c 'CREATE DATABASE sonataflow;' || echo WARNING: Could not create database" {{- end }} restartPolicy: Never backoffLimit: 2 diff --git a/charts/backstage/values.schema.json b/charts/backstage/values.schema.json index d9148d43..aa9b6eb1 100644 --- a/charts/backstage/values.schema.json +++ b/charts/backstage/values.schema.json @@ -155,11 +155,21 @@ "title": "eventing configuration", "type": "object" }, + "externalDBHost": { + "additionalProperties": false, + "title": "Host for the user-configured external Database", + "type": "string" + }, "externalDBName": { "additionalProperties": false, "title": "Name for the user-configured external Database", "type": "string" }, + "externalDBPort": { + "additionalProperties": false, + "title": "Port for the user-configured external Database", + "type": "string" + }, "externalDBsecretRef": { "additionalProperties": false, "title": "Secret name for the user-created secret to connect an external DB", diff --git a/charts/backstage/values.schema.tmpl.json b/charts/backstage/values.schema.tmpl.json index 73110f0c..02e31075 100644 --- a/charts/backstage/values.schema.tmpl.json +++ b/charts/backstage/values.schema.tmpl.json @@ -322,6 +322,16 @@ "type": "string", "additionalProperties": false }, + "externalDBHost": { + "title": "Host for the user-configured external Database", + "type": "string", + "additionalProperties": false + }, + "externalDBPort": { + "title": "Port for the user-configured external Database", + "type": "string", + "additionalProperties": false + }, "initContainerImage": { "title": "Image for the init container used by the create-db job", "type": "string", diff --git a/charts/backstage/values.yaml b/charts/backstage/values.yaml index 474f1104..0088345c 100644 --- a/charts/backstage/values.yaml +++ b/charts/backstage/values.yaml @@ -375,6 +375,12 @@ orchestrator: # -- Name for the user-configured external Database externalDBName: "" + # -- Host for the user-configured external Database + externalDBHost: "" + + # -- Port for the user-configured external Database + externalDBPort: "" + # -- Image for the init container used by the create-db job initContainerImage: "{{ .Values.upstream.postgresql.image.registry }}/{{ .Values.upstream.postgresql.image.repository }}:{{ .Values.upstream.postgresql.image.tag }}" From 4ca06a626d529b3a23b99ef88ad25362d6bb9e45 Mon Sep 17 00:00:00 2001 From: Elai Shalev Date: Sun, 22 Jun 2025 10:19:53 +0300 Subject: [PATCH 2/6] fixes after review --- charts/backstage/templates/sonataflows.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/charts/backstage/templates/sonataflows.yaml b/charts/backstage/templates/sonataflows.yaml index 182e2681..8f88590b 100644 --- a/charts/backstage/templates/sonataflows.yaml +++ b/charts/backstage/templates/sonataflows.yaml @@ -49,7 +49,7 @@ spec: name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef }} userKey: POSTGRES_USER passwordKey: POSTGRES_PASSWORD - jdbcUrl: jdbc:postgresql://{{ .Values.orchestrator.sonataflowPlatform.externalDBHost }}:{{ .Values.orchestrator.sonataflowPlatform.externalDBPort }}/{{ .Values.orchestrator.sonataflowPlatform.externalDBName }}?currentSchema=data-index-service + jdbcUrl: jdbc:postgresql://{{ .Values.orchestrator.sonataflowPlatform.externalDBHost }}:{{ .Values.orchestrator.sonataflowPlatform.externalDBPort }}/sonataflow?currentSchema=data-index-service {{- end }} {{- if .Values.orchestrator.sonataflowPlatform.dataIndexImage }} podTemplate: @@ -71,10 +71,10 @@ spec: databaseName: sonataflow {{- else }} secretRef: - name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef}} + name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef }} userKey: POSTGRES_USER passwordKey: POSTGRES_PASSWORD - jdbcUrl: jdbc:postgresql://{{ .Values.orchestrator.sonataflowPlatform.externalDBHost }}:{{ .Values.orchestrator.sonataflowPlatform.externalDBPort }}/{{ .Values.orchestrator.sonataflowPlatform.externalDBName }}?currentSchema=jobs-service + jdbcUrl: jdbc:postgresql://{{ .Values.orchestrator.sonataflowPlatform.externalDBHost }}:{{ .Values.orchestrator.sonataflowPlatform.externalDBPort }}/sonataflow?currentSchema=jobs-service {{- end }} {{- if .Values.orchestrator.sonataflowPlatform.jobServiceImage }} podTemplate: @@ -128,12 +128,12 @@ spec: - name: POSTGRES_HOST valueFrom: secretKeyRef: - name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef}} + name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef }} key: POSTGRES_HOST - name: POSTGRES_PORT valueFrom: secretKeyRef: - name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef}} + name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef }} key: POSTGRES_PORT {{- end }} containers: @@ -164,12 +164,12 @@ spec: - name: POSTGRES_HOST valueFrom: secretKeyRef: - name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef}} + name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef }} key: POSTGRES_HOST - name: POSTGRES_USER valueFrom: secretKeyRef: - name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef}} + name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef }} key: POSTGRES_USER {{- end }} command: [ "sh", "-c" ] From cca4c4fbb4e1fdea794fd811066a0f3ef4129e93 Mon Sep 17 00:00:00 2001 From: Elai Shalev Date: Sun, 22 Jun 2025 10:31:38 +0300 Subject: [PATCH 3/6] rebase and chart bump --- charts/backstage/Chart.yaml | 2 +- charts/backstage/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/backstage/Chart.yaml b/charts/backstage/Chart.yaml index afa4c66c..c0a10837 100644 --- a/charts/backstage/Chart.yaml +++ b/charts/backstage/Chart.yaml @@ -50,4 +50,4 @@ sources: [] # Versions are expected to follow Semantic Versioning (https://semver.org/) # Note that when this chart is published to https://github.com/openshift-helm-charts/charts # it will follow the RHDH versioning 1.y.z -version: 4.2.9 +version: 4.2.10 diff --git a/charts/backstage/README.md b/charts/backstage/README.md index 4bbaa5bc..1ebf82c6 100644 --- a/charts/backstage/README.md +++ b/charts/backstage/README.md @@ -1,7 +1,7 @@ # RHDH Backstage Helm Chart for OpenShift (Community Version) -![Version: 4.2.9](https://img.shields.io/badge/Version-4.2.9-informational?style=flat-square) +![Version: 4.2.10](https://img.shields.io/badge/Version-4.2.10-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) Red Hat Developer Hub is a Red Hat supported version of Backstage. From 09d084987ae42e89bb9808c2d8b91d8173951353 Mon Sep 17 00:00:00 2001 From: Elai Shalev Date: Tue, 24 Jun 2025 11:18:49 +0300 Subject: [PATCH 4/6] adding port and password to psql command --- charts/backstage/templates/sonataflows.yaml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/charts/backstage/templates/sonataflows.yaml b/charts/backstage/templates/sonataflows.yaml index 8f88590b..3911e265 100644 --- a/charts/backstage/templates/sonataflows.yaml +++ b/charts/backstage/templates/sonataflows.yaml @@ -123,6 +123,7 @@ spec: echo 'Waiting for DB...' sleep 2 done + echo 'Connection made!' {{- if not .Values.upstream.postgresql.enabled }} env: - name: POSTGRES_HOST @@ -171,14 +172,24 @@ spec: secretKeyRef: name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef }} key: POSTGRES_USER + - name: POSTGRES_PORT + valueFrom: + secretKeyRef: + name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef }} + key: POSTGRES_PORT + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef }} + key: POSTGRES_PASSWORD {{- end }} command: [ "sh", "-c" ] {{- if .Values.upstream.postgresql.enabled }} args: - - "psql -h {{ .Release.Name }}-postgresql -U postgres -c 'CREATE DATABASE sonataflow;' || echo WARNING: Could not create database" + - "psql -h {{ .Release.Name }}-postgresql -p 5432 -U postgres -c 'CREATE DATABASE sonataflow;' || echo WARNING: Could not create database" {{- else }} args: - - "psql -h ${POSTGRES_HOST} -U ${POSTGRES_USER} -d {{ .Values.orchestrator.sonataflowPlatform.externalDBName }} -c 'CREATE DATABASE sonataflow;' || echo WARNING: Could not create database" + - "psql -h ${POSTGRES_HOST} -p ${POSTGRES_PORT} -U ${POSTGRES_USER} -d {{ .Values.orchestrator.sonataflowPlatform.externalDBName }} -c 'CREATE DATABASE sonataflow;' || echo WARNING: Could not create database" {{- end }} restartPolicy: Never backoffLimit: 2 From e8c4ee6057a5bd7d37f36aaf297e171aede4a95f Mon Sep 17 00:00:00 2001 From: Elai Shalev Date: Tue, 24 Jun 2025 11:20:24 +0300 Subject: [PATCH 5/6] readme changes --- charts/backstage/README.md | 2 +- charts/backstage/README.md.gotmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/backstage/README.md b/charts/backstage/README.md index 1ebf82c6..ff7c5620 100644 --- a/charts/backstage/README.md +++ b/charts/backstage/README.md @@ -381,7 +381,7 @@ and populate the following values in the values.yaml: The values for externalDBHost and externalDBPort should match the ones configured in the cred-secret. Please note that `externalDBName` is the name of the user-configured existing database, not the database that the orchestrator and sonataflow resources will use. -A Job will run to create the 'sonataflow' databse in the external database for the workflows to use. +A Job will run to create the 'sonataflow' database in the external database for the workflows to use. Finally, install the Helm Chart (including [setting up the external DB](https://github.com/redhat-developer/rhdh-chart/blob/main/docs/external-db.md)): ``` diff --git a/charts/backstage/README.md.gotmpl b/charts/backstage/README.md.gotmpl index 3dbd195d..14a3e574 100644 --- a/charts/backstage/README.md.gotmpl +++ b/charts/backstage/README.md.gotmpl @@ -316,7 +316,7 @@ and populate the following values in the values.yaml: The values for externalDBHost and externalDBPort should match the ones configured in the cred-secret. Please note that `externalDBName` is the name of the user-configured existing database, not the database that the orchestrator and sonataflow resources will use. -A Job will run to create the 'sonataflow' databse in the external database for the workflows to use. +A Job will run to create the 'sonataflow' database in the external database for the workflows to use. Finally, install the Helm Chart (including [setting up the external DB](https://github.com/redhat-developer/rhdh-chart/blob/main/docs/external-db.md)): ``` From 83f64a3cc8e369182d9d4e5a1c184c7ed6d8f3ea Mon Sep 17 00:00:00 2001 From: Elai Shalev Date: Tue, 24 Jun 2025 14:13:15 +0300 Subject: [PATCH 6/6] secret name change --- charts/backstage/templates/sonataflows.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/backstage/templates/sonataflows.yaml b/charts/backstage/templates/sonataflows.yaml index 3911e265..d845c7cd 100644 --- a/charts/backstage/templates/sonataflows.yaml +++ b/charts/backstage/templates/sonataflows.yaml @@ -177,7 +177,7 @@ spec: secretKeyRef: name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef }} key: POSTGRES_PORT - - name: POSTGRES_PASSWORD + - name: PGPASSWORD valueFrom: secretKeyRef: name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef }}