Skip to content

Commit d410e9c

Browse files
authored
Add relational-jdbc to helm (#1937)
Motivation for the Change Polaris needs to support relational-jdbc as the default persistence type for simpler database configuration and better cloud-native deployment experience. Description of the Status Quo (Current Behavior) Currently, the Helm chart only supports eclipse-link persistence type as the default, which requires complex JPA configuration with persistence.xml files. Desired Behavior Add relational-jdbc persistence type support to Helm chart Use relational-jdbc as the default persistence type Inject JDBC configuration (username, password, jdbc_url) through Kubernetes Secrets as environment variables Maintain backward compatibility with eclipse-link Additional Details Updated persistence-values.yaml for CI testing Updated test coverage for relational-jdbc configuration JDBC credentials are injected via QUARKUS_DATASOURCE_* environment variables from Secret Secret keys: username, password, jdbc_url
1 parent f6ae855 commit d410e9c

File tree

7 files changed

+68
-36
lines changed

7 files changed

+68
-36
lines changed

helm/polaris/ci/fixtures/persistence.yaml

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,6 @@ metadata:
2323
name: polaris-persistence
2424
type: Opaque
2525
stringData:
26-
persistence.xml: |-
27-
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
28-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
29-
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
30-
<persistence-unit name="polaris" transaction-type="RESOURCE_LOCAL">
31-
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
32-
<class>org.apache.polaris.extension.persistence.impl.eclipselink.models.ModelEntity</class>
33-
<class>org.apache.polaris.extension.persistence.impl.eclipselink.models.ModelEntityActive</class>
34-
<class>org.apache.polaris.extension.persistence.impl.eclipselink.models.ModelEntityChangeTracking</class>
35-
<class>org.apache.polaris.extension.persistence.impl.eclipselink.models.ModelEntityDropped</class>
36-
<class>org.apache.polaris.extension.persistence.impl.eclipselink.models.ModelGrantRecord</class>
37-
<class>org.apache.polaris.extension.persistence.impl.eclipselink.models.ModelPrincipalSecrets</class>
38-
<class>org.apache.polaris.extension.persistence.impl.eclipselink.models.ModelSequenceId</class>
39-
<shared-cache-mode>NONE</shared-cache-mode>
40-
<properties>
41-
<property name="jakarta.persistence.jdbc.url"
42-
value="jdbc:postgresql://postgres:5432/{realm}"/>
43-
<property name="jakarta.persistence.jdbc.user" value="postgres"/>
44-
<property name="jakarta.persistence.jdbc.password" value="postgres"/>
45-
<property name="jakarta.persistence.schema-generation.database.action" value="create"/>
46-
<property name="eclipselink.logging.level.sql" value="FINE"/>
47-
<property name="eclipselink.logging.parameters" value="true"/>
48-
<property name="eclipselink.persistence-context.flush-mode" value="auto"/>
49-
<property name="eclipselink.connection-pool.default.initial" value="1" />
50-
<property name="eclipselink.connection-pool.default.min" value="1" />
51-
<property name="eclipselink.connection-pool.default.max" value="1" />
52-
<property name="eclipselink.session.customizer" value="org.apache.polaris.extension.persistence.impl.eclipselink.PolarisEclipseLinkSessionCustomizer" />
53-
<property name="eclipselink.transaction.join-existing" value="true" />
54-
</properties>
55-
</persistence-unit>
56-
</persistence>
26+
username: "postgres"
27+
password: "postgres"
28+
jdbcUrl: "jdbc:postgresql://postgres:5432/POLARIS"

helm/polaris/ci/persistence-values.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ logging:
3333
size: 50Mi
3434

3535
persistence:
36-
type: eclipse-link
37-
eclipseLink:
36+
type: relational-jdbc
37+
relationalJdbc:
38+
dbKind: postgres
3839
secret:
3940
name: polaris-persistence

helm/polaris/templates/configmap.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ data:
5353
{{- $_ = set $map "polaris.persistence.eclipselink.persistence-unit" .Values.persistence.eclipseLink.persistenceUnit -}}
5454
{{- $_ = set $map "polaris.persistence.eclipselink.configuration-file" (printf "%s/persistence.xml" .Values.image.configDir ) -}}
5555
{{- end -}}
56+
{{- if eq .Values.persistence.type "relational-jdbc" -}}
57+
{{- if .Values.persistence.relationalJdbc.dbKind -}}
58+
{{- $_ = set $map "quarkus.datasource.db-kind" .Values.persistence.relationalJdbc.dbKind -}}
59+
{{- end -}}
60+
{{- end -}}
5661
5762
{{- /* File IO */ -}}
5863
{{- $_ = set $map "polaris.file-io.type" .Values.fileIo.type -}}

helm/polaris/templates/deployment.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,20 @@ spec:
7272
{{- end }}
7373
image: "{{ tpl .Values.image.repository . }}:{{ tpl .Values.image.tag . | default .Chart.Version }}"
7474
imagePullPolicy: {{ tpl .Values.image.pullPolicy . }}
75-
{{ if or .Values.storage.secret.name .Values.extraEnv -}}
75+
{{ if or .Values.storage.secret.name .Values.persistence.relationalJdbc.secret.name .Values.extraEnv -}}
7676
env:
7777
{{- include "polaris.secretToEnv" (list .Values.storage.secret "awsAccessKeyId" "polaris.storage.aws.access-key") | indent 12 -}}
7878
{{- include "polaris.secretToEnv" (list .Values.storage.secret "awsSecretAccessKey" "polaris.storage.aws.secret-key") | indent 12 -}}
7979
{{- include "polaris.secretToEnv" (list .Values.storage.secret "gcpToken" "polaris.storage.gcp.token") | indent 12 -}}
80+
{{- if and ( eq .Values.persistence.type "relational-jdbc" ) .Values.persistence.relationalJdbc.secret.name }}
81+
{{- range $key, $envVar := dict "username" "username" "password" "password" "jdbcUrl" "jdbc.url" }}
82+
- name: quarkus.datasource.{{ $envVar }}
83+
valueFrom:
84+
secretKeyRef:
85+
name: {{ $.Values.persistence.relationalJdbc.secret.name }}
86+
key: {{ $key }}
87+
{{- end }}
88+
{{- end }}
8089
{{- if .Values.extraEnv -}}
8190
{{- tpl (toYaml .Values.extraEnv) . | nindent 12 -}}
8291
{{- end -}}

helm/polaris/tests/configmap_test.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ tests:
110110
- matchRegex: { path: 'data["application.properties"]', pattern: "polaris.persistence.eclipselink.persistence-unit=polaris" }
111111
- matchRegex: { path: 'data["application.properties"]', pattern: "polaris.persistence.eclipselink.configuration-file=/deployments/config/persistence.xml" }
112112

113+
- it: should configure relational-jdbc persistence
114+
set:
115+
persistence: { type: "relational-jdbc", relationalJdbc: { secret: { name: "polaris-persistence" } } }
116+
asserts:
117+
- matchRegex: { path: 'data["application.properties"]', pattern: "polaris.persistence.type=relational-jdbc" }
118+
113119
- it: should configure file-io
114120
set:
115121
fileIo.type: "custom"

helm/polaris/tests/deployment_test.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,35 @@ tests:
10201020
- key: custom.xml
10211021
path: persistence.xml
10221022

1023+
- it: should set relational-jdbc persistence environment variables
1024+
set:
1025+
persistence: { type: "relational-jdbc", dbKind: postgres, relationalJdbc: { secret: { name: "polaris-persistence" } } }
1026+
asserts:
1027+
- contains:
1028+
path: spec.template.spec.containers[0].env
1029+
content:
1030+
name: quarkus.datasource.username
1031+
valueFrom:
1032+
secretKeyRef:
1033+
name: polaris-persistence
1034+
key: username
1035+
- contains:
1036+
path: spec.template.spec.containers[0].env
1037+
content:
1038+
name: quarkus.datasource.password
1039+
valueFrom:
1040+
secretKeyRef:
1041+
name: polaris-persistence
1042+
key: password
1043+
- contains:
1044+
path: spec.template.spec.containers[0].env
1045+
content:
1046+
name: quarkus.datasource.jdbc.url
1047+
valueFrom:
1048+
secretKeyRef:
1049+
name: polaris-persistence
1050+
key: jdbcUrl
1051+
10231052
- it: should configure volume for file logging
10241053
set:
10251054
logging.file.enabled: true

helm/polaris/values.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,18 @@ features:
521521

522522
# -- Polaris persistence configuration.
523523
persistence:
524-
# -- The type of persistence to use. Two built-in types are supported: in-memory and eclipse-link.
525-
type: eclipse-link # in-memory
524+
# -- The type of persistence to use. Two built-in types are supported: in-memory and relational-jdbc.
525+
# The eclipse-link type is also supported but is deprecated.
526+
type: in-memory # relational-jdbc
527+
# -- The configuration for the relational-jdbc persistence manager.
528+
relationalJdbc:
529+
# -- The type of database to use. Valid values are: h2, postgres.
530+
dbKind: postgres # h2
531+
# -- The secret name to pull the database connection properties from.
532+
secret:
533+
# -- The secret name to pull the database connection properties from.
534+
name: ~
535+
526536
# -- The configuration for the eclipse-link persistence manager.
527537
eclipseLink:
528538
# -- The secret name to pull persistence.xml from.

0 commit comments

Comments
 (0)