diff --git a/helm/polaris/ci/fixtures/persistence.yaml b/helm/polaris/ci/fixtures/persistence.yaml index 9b6e6cab94..e1bcb29298 100644 --- a/helm/polaris/ci/fixtures/persistence.yaml +++ b/helm/polaris/ci/fixtures/persistence.yaml @@ -23,34 +23,6 @@ metadata: name: polaris-persistence type: Opaque stringData: - persistence.xml: |- - - - org.eclipse.persistence.jpa.PersistenceProvider - org.apache.polaris.extension.persistence.impl.eclipselink.models.ModelEntity - org.apache.polaris.extension.persistence.impl.eclipselink.models.ModelEntityActive - org.apache.polaris.extension.persistence.impl.eclipselink.models.ModelEntityChangeTracking - org.apache.polaris.extension.persistence.impl.eclipselink.models.ModelEntityDropped - org.apache.polaris.extension.persistence.impl.eclipselink.models.ModelGrantRecord - org.apache.polaris.extension.persistence.impl.eclipselink.models.ModelPrincipalSecrets - org.apache.polaris.extension.persistence.impl.eclipselink.models.ModelSequenceId - NONE - - - - - - - - - - - - - - - - + username: "postgres" + password: "postgres" + jdbcUrl: "jdbc:postgresql://postgres:5432/POLARIS" diff --git a/helm/polaris/ci/persistence-values.yaml b/helm/polaris/ci/persistence-values.yaml index 3d83874399..5f684d3500 100644 --- a/helm/polaris/ci/persistence-values.yaml +++ b/helm/polaris/ci/persistence-values.yaml @@ -33,7 +33,8 @@ logging: size: 50Mi persistence: - type: eclipse-link - eclipseLink: + type: relational-jdbc + relationalJdbc: + dbKind: postgres secret: name: polaris-persistence diff --git a/helm/polaris/templates/configmap.yaml b/helm/polaris/templates/configmap.yaml index 6d12fbd7e1..82443fdfec 100644 --- a/helm/polaris/templates/configmap.yaml +++ b/helm/polaris/templates/configmap.yaml @@ -53,6 +53,11 @@ data: {{- $_ = set $map "polaris.persistence.eclipselink.persistence-unit" .Values.persistence.eclipseLink.persistenceUnit -}} {{- $_ = set $map "polaris.persistence.eclipselink.configuration-file" (printf "%s/persistence.xml" .Values.image.configDir ) -}} {{- end -}} + {{- if eq .Values.persistence.type "relational-jdbc" -}} + {{- if .Values.persistence.relationalJdbc.dbKind -}} + {{- $_ = set $map "quarkus.datasource.db-kind" .Values.persistence.relationalJdbc.dbKind -}} + {{- end -}} + {{- end -}} {{- /* File IO */ -}} {{- $_ = set $map "polaris.file-io.type" .Values.fileIo.type -}} diff --git a/helm/polaris/templates/deployment.yaml b/helm/polaris/templates/deployment.yaml index a444cc5076..d6fec4c1e1 100644 --- a/helm/polaris/templates/deployment.yaml +++ b/helm/polaris/templates/deployment.yaml @@ -72,11 +72,20 @@ spec: {{- end }} image: "{{ tpl .Values.image.repository . }}:{{ tpl .Values.image.tag . | default .Chart.Version }}" imagePullPolicy: {{ tpl .Values.image.pullPolicy . }} - {{ if or .Values.storage.secret.name .Values.extraEnv -}} + {{ if or .Values.storage.secret.name .Values.persistence.relationalJdbc.secret.name .Values.extraEnv -}} env: {{- include "polaris.secretToEnv" (list .Values.storage.secret "awsAccessKeyId" "polaris.storage.aws.access-key") | indent 12 -}} {{- include "polaris.secretToEnv" (list .Values.storage.secret "awsSecretAccessKey" "polaris.storage.aws.secret-key") | indent 12 -}} {{- include "polaris.secretToEnv" (list .Values.storage.secret "gcpToken" "polaris.storage.gcp.token") | indent 12 -}} + {{- if and ( eq .Values.persistence.type "relational-jdbc" ) .Values.persistence.relationalJdbc.secret.name }} + {{- range $key, $envVar := dict "username" "username" "password" "password" "jdbcUrl" "jdbc.url" }} + - name: quarkus.datasource.{{ $envVar }} + valueFrom: + secretKeyRef: + name: {{ $.Values.persistence.relationalJdbc.secret.name }} + key: {{ $key }} + {{- end }} + {{- end }} {{- if .Values.extraEnv -}} {{- tpl (toYaml .Values.extraEnv) . | nindent 12 -}} {{- end -}} diff --git a/helm/polaris/tests/configmap_test.yaml b/helm/polaris/tests/configmap_test.yaml index 562adad220..875469dac5 100644 --- a/helm/polaris/tests/configmap_test.yaml +++ b/helm/polaris/tests/configmap_test.yaml @@ -110,6 +110,12 @@ tests: - matchRegex: { path: 'data["application.properties"]', pattern: "polaris.persistence.eclipselink.persistence-unit=polaris" } - matchRegex: { path: 'data["application.properties"]', pattern: "polaris.persistence.eclipselink.configuration-file=/deployments/config/persistence.xml" } + - it: should configure relational-jdbc persistence + set: + persistence: { type: "relational-jdbc", relationalJdbc: { secret: { name: "polaris-persistence" } } } + asserts: + - matchRegex: { path: 'data["application.properties"]', pattern: "polaris.persistence.type=relational-jdbc" } + - it: should configure file-io set: fileIo.type: "custom" diff --git a/helm/polaris/tests/deployment_test.yaml b/helm/polaris/tests/deployment_test.yaml index 1d457adef5..00c5eb52cd 100644 --- a/helm/polaris/tests/deployment_test.yaml +++ b/helm/polaris/tests/deployment_test.yaml @@ -1020,6 +1020,35 @@ tests: - key: custom.xml path: persistence.xml + - it: should set relational-jdbc persistence environment variables + set: + persistence: { type: "relational-jdbc", dbKind: postgres, relationalJdbc: { secret: { name: "polaris-persistence" } } } + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: quarkus.datasource.username + valueFrom: + secretKeyRef: + name: polaris-persistence + key: username + - contains: + path: spec.template.spec.containers[0].env + content: + name: quarkus.datasource.password + valueFrom: + secretKeyRef: + name: polaris-persistence + key: password + - contains: + path: spec.template.spec.containers[0].env + content: + name: quarkus.datasource.jdbc.url + valueFrom: + secretKeyRef: + name: polaris-persistence + key: jdbcUrl + - it: should configure volume for file logging set: logging.file.enabled: true diff --git a/helm/polaris/values.yaml b/helm/polaris/values.yaml index 5cf964f20c..28cc1bb025 100644 --- a/helm/polaris/values.yaml +++ b/helm/polaris/values.yaml @@ -521,8 +521,18 @@ features: # -- Polaris persistence configuration. persistence: - # -- The type of persistence to use. Two built-in types are supported: in-memory and eclipse-link. - type: eclipse-link # in-memory + # -- The type of persistence to use. Two built-in types are supported: in-memory and relational-jdbc. + # The eclipse-link type is also supported but is deprecated. + type: in-memory # relational-jdbc + # -- The configuration for the relational-jdbc persistence manager. + relationalJdbc: + # -- The type of database to use. Valid values are: h2, postgres. + dbKind: postgres # h2 + # -- The secret name to pull the database connection properties from. + secret: + # -- The secret name to pull the database connection properties from. + name: ~ + # -- The configuration for the eclipse-link persistence manager. eclipseLink: # -- The secret name to pull persistence.xml from.