Skip to content

Add relational-jdbc to helm #1937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 3 additions & 31 deletions helm/polaris/ci/fixtures/persistence.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,6 @@ metadata:
name: polaris-persistence
type: Opaque
stringData:
persistence.xml: |-
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="polaris" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.apache.polaris.extension.persistence.impl.eclipselink.models.ModelEntity</class>
<class>org.apache.polaris.extension.persistence.impl.eclipselink.models.ModelEntityActive</class>
<class>org.apache.polaris.extension.persistence.impl.eclipselink.models.ModelEntityChangeTracking</class>
<class>org.apache.polaris.extension.persistence.impl.eclipselink.models.ModelEntityDropped</class>
<class>org.apache.polaris.extension.persistence.impl.eclipselink.models.ModelGrantRecord</class>
<class>org.apache.polaris.extension.persistence.impl.eclipselink.models.ModelPrincipalSecrets</class>
<class>org.apache.polaris.extension.persistence.impl.eclipselink.models.ModelSequenceId</class>
<shared-cache-mode>NONE</shared-cache-mode>
<properties>
<property name="jakarta.persistence.jdbc.url"
value="jdbc:postgresql://postgres:5432/{realm}"/>
<property name="jakarta.persistence.jdbc.user" value="postgres"/>
<property name="jakarta.persistence.jdbc.password" value="postgres"/>
<property name="jakarta.persistence.schema-generation.database.action" value="create"/>
<property name="eclipselink.logging.level.sql" value="FINE"/>
<property name="eclipselink.logging.parameters" value="true"/>
<property name="eclipselink.persistence-context.flush-mode" value="auto"/>
<property name="eclipselink.connection-pool.default.initial" value="1" />
<property name="eclipselink.connection-pool.default.min" value="1" />
<property name="eclipselink.connection-pool.default.max" value="1" />
<property name="eclipselink.session.customizer" value="org.apache.polaris.extension.persistence.impl.eclipselink.PolarisEclipseLinkSessionCustomizer" />
<property name="eclipselink.transaction.join-existing" value="true" />
</properties>
</persistence-unit>
</persistence>
username: "postgres"
password: "postgres"
jdbcUrl: "jdbc:postgresql://postgres:5432/POLARIS"
5 changes: 3 additions & 2 deletions helm/polaris/ci/persistence-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ logging:
size: 50Mi

persistence:
type: eclipse-link
eclipseLink:
type: relational-jdbc
relationalJdbc:
dbKind: postgres
secret:
name: polaris-persistence
5 changes: 5 additions & 0 deletions helm/polaris/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quarkus.datasource.db-kind is a build-time setting. It is probably not useful to set it in helm.

https://quarkus.io/guides/datasource#quarkus-datasource_quarkus-datasource-db-kind

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cf. #1945

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jparkzz : I still believe this configuration setting is not necessary and could be misleading because the value is not really changeable at the helm level. Would you mind following you with another PR to remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you prefer to configure dbKind within the secret? With current chart, even if we set it in the secret, I believe the value would still be explicitly visible in the helm chart when it's injected as an environment variable

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, my point is that db-kind can only be configured at build time (link above). It is not possible to overwrite that in Helm.

ATM only PostgreSQL is supported.

{{- end -}}
{{- end -}}

{{- /* File IO */ -}}
{{- $_ = set $map "polaris.file-io.type" .Values.fileIo.type -}}
Expand Down
11 changes: 10 additions & 1 deletion helm/polaris/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand Down
6 changes: 6 additions & 0 deletions helm/polaris/tests/configmap_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
29 changes: 29 additions & 0 deletions helm/polaris/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions helm/polaris/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading