From 7cd208c4d00ad61c81046d88be9da9a2872d3f33 Mon Sep 17 00:00:00 2001 From: Fred Campos Date: Fri, 4 Sep 2026 16:18:26 +0200 Subject: [PATCH 1/2] Add extraVolumes and extraVolumeMounts Helm values for mounting files into the operator pod --- docs/cluster-connection.md | 14 +++++++++++- operator/src/main/helm/values.yaml | 6 +++++ operator/src/main/kubernetes/kubernetes.yml | 4 ++++ operator/src/main/resources/application.yml | 22 +++++++++++++++++++ .../aboutbits/postgresql/helm/HelmTest.java | 11 +++++++--- 5 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 operator/src/main/helm/values.yaml diff --git a/docs/cluster-connection.md b/docs/cluster-connection.md index 8f1b922..98d432b 100644 --- a/docs/cluster-connection.md +++ b/docs/cluster-connection.md @@ -75,7 +75,19 @@ spec: > **Note:** The volume source can be any type that provides a file. -> **Note:** The Helm chart does not support extra volumes yet. +> **Tip:** When using the Helm chart, configure volumes via `extraVolumes` and `extraVolumeMounts` values: +> +> ```yaml +> app: +> extraVolumes: +> - name: db-credentials +> secret: +> secretName: db-credentials-secret +> extraVolumeMounts: +> - name: db-credentials +> mountPath: /mnt/secrets +> readOnly: true +> ``` ### Examples diff --git a/operator/src/main/helm/values.yaml b/operator/src/main/helm/values.yaml new file mode 100644 index 0000000..5c15947 --- /dev/null +++ b/operator/src/main/helm/values.yaml @@ -0,0 +1,6 @@ +--- +# Workaround: quarkus-helm generates `extraVolumeMounts: {}` (object) instead of `[]` (array) +# when the value path uses a container name filter like `containers.(name == ...)`. +# This merge file corrects the default value type. +app: + extraVolumeMounts: [] diff --git a/operator/src/main/kubernetes/kubernetes.yml b/operator/src/main/kubernetes/kubernetes.yml index 037464e..a3f8dc3 100644 --- a/operator/src/main/kubernetes/kubernetes.yml +++ b/operator/src/main/kubernetes/kubernetes.yml @@ -8,3 +8,7 @@ spec: spec: affinity: {} imagePullSecrets: [~] + volumes: [~] + containers: + - name: postgresql-operator + volumeMounts: [~] diff --git a/operator/src/main/resources/application.yml b/operator/src/main/resources/application.yml index 3b5f766..ecbfdfa 100644 --- a/operator/src/main/resources/application.yml +++ b/operator/src/main/resources/application.yml @@ -113,6 +113,22 @@ quarkus: paths: - (kind == Deployment).spec.template.spec.affinity description: Kubernetes affinity configuration for Pod scheduling + extra-volumes: + property: extraVolumes + value: + - null + paths: + - (kind == Deployment).spec.template.spec.volumes + expression: "{{- if eq (toYaml .Values.app.extraVolumes | trim) \"- {}\" }} null{{- else }}{{ toYaml .Values.app.extraVolumes | nindent 8 }}{{- end }}" + description: Extra volumes to add to the operator pod + extra-volume-mounts: + property: extraVolumeMounts + value: + - null + paths: + - (kind == Deployment).spec.template.spec.containers.(name == postgresql-operator).volumeMounts + expression: "{{- if eq (toYaml .Values.app.extraVolumeMounts | trim) \"- {}\" }} null{{- else }}{{- toYaml .Values.app.extraVolumeMounts | nindent 12 }}{{- end }}" + description: Extra volume mounts to add to the operator container console-color: property: envs.QUARKUS_CONSOLE_COLOR value-as-bool: ${quarkus.console.color} @@ -130,6 +146,12 @@ quarkus: "affinity": name: app.affinity type: object + "extraVolumeMounts": + name: app.extraVolumeMounts + type: array + "extraVolumes": + name: app.extraVolumes + type: array expressions: release-name-labels: expression: "{{ .Release.Name }}" diff --git a/operator/src/test/java/it/aboutbits/postgresql/helm/HelmTest.java b/operator/src/test/java/it/aboutbits/postgresql/helm/HelmTest.java index 7b864be..a8c784e 100644 --- a/operator/src/test/java/it/aboutbits/postgresql/helm/HelmTest.java +++ b/operator/src/test/java/it/aboutbits/postgresql/helm/HelmTest.java @@ -6,6 +6,7 @@ import io.quarkus.test.junit.QuarkusTest; import io.smallrye.common.process.ProcessBuilder; import lombok.extern.slf4j.Slf4j; +import org.assertj.core.api.InstanceOfAssertFactories; import org.eclipse.microprofile.config.inject.ConfigProperty; import org.jspecify.annotations.NullMarked; import org.junit.jupiter.api.DisplayName; @@ -92,6 +93,8 @@ void helmInstall_createsDeployment() throws IOException { Objects.requireNonNull(appValues, "appValues should not be null"); assertThat(appValues.get("image")).isNotNull(); + assertThat(appValues).containsKey("extraVolumes"); + assertThat(appValues).containsKey("extraVolumeMounts"); assertThat(chartPath.resolve("LICENSE")).exists(); assertThat(chartPath.resolve("README.md")).exists(); @@ -173,9 +176,11 @@ void helmInstall_createsDeployment() throws IOException { assertThat(deployment.getSpec()) .isNotNull() - .satisfies(spec -> - assertThat(spec.getTemplate().getSpec().getImagePullSecrets()).isEmpty() - ); + .satisfies(spec -> { + assertThat(spec.getTemplate().getSpec().getImagePullSecrets()).isEmpty(); + assertThat(spec.getTemplate().getSpec().getVolumes()).isEmpty(); + assertThat(spec.getTemplate().getSpec().getContainers().getFirst().getVolumeMounts()).isEmpty(); + }); var selector = deployment.getSpec().getSelector(); From ae09a32ab04e6c6175a642676662255299a33f6f Mon Sep 17 00:00:00 2001 From: Fred Campos Date: Fri, 4 Sep 2026 16:22:36 +0200 Subject: [PATCH 2/2] cleanup imports --- .../src/test/java/it/aboutbits/postgresql/helm/HelmTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/operator/src/test/java/it/aboutbits/postgresql/helm/HelmTest.java b/operator/src/test/java/it/aboutbits/postgresql/helm/HelmTest.java index a8c784e..13a952d 100644 --- a/operator/src/test/java/it/aboutbits/postgresql/helm/HelmTest.java +++ b/operator/src/test/java/it/aboutbits/postgresql/helm/HelmTest.java @@ -6,7 +6,6 @@ import io.quarkus.test.junit.QuarkusTest; import io.smallrye.common.process.ProcessBuilder; import lombok.extern.slf4j.Slf4j; -import org.assertj.core.api.InstanceOfAssertFactories; import org.eclipse.microprofile.config.inject.ConfigProperty; import org.jspecify.annotations.NullMarked; import org.junit.jupiter.api.DisplayName;