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 cb3468f3..ff7c5620 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. @@ -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' 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)): ``` 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..14a3e574 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' 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)): ``` 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..d845c7cd 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 }}/sonataflow?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}} + 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 }}/sonataflow?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,31 @@ 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 + echo 'Connection made!' +{{- 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 +155,41 @@ 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 + - name: POSTGRES_PORT + valueFrom: + secretKeyRef: + name: {{ .Values.orchestrator.sonataflowPlatform.externalDBsecretRef }} + key: POSTGRES_PORT + - name: PGPASSWORD + 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 }} - 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} -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 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 }}"