Skip to content

Commit 7cd208c

Browse files
author
Fred Campos
committed
Add extraVolumes and extraVolumeMounts Helm values for mounting files into the operator pod
1 parent 971582e commit 7cd208c

5 files changed

Lines changed: 53 additions & 4 deletions

File tree

docs/cluster-connection.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,19 @@ spec:
7575
7676
> **Note:** The volume source can be any type that provides a file.
7777
78-
> **Note:** The Helm chart does not support extra volumes yet.
78+
> **Tip:** When using the Helm chart, configure volumes via `extraVolumes` and `extraVolumeMounts` values:
79+
>
80+
> ```yaml
81+
> app:
82+
> extraVolumes:
83+
> - name: db-credentials
84+
> secret:
85+
> secretName: db-credentials-secret
86+
> extraVolumeMounts:
87+
> - name: db-credentials
88+
> mountPath: /mnt/secrets
89+
> readOnly: true
90+
> ```
7991

8092
### Examples
8193

operator/src/main/helm/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
# Workaround: quarkus-helm generates `extraVolumeMounts: {}` (object) instead of `[]` (array)
3+
# when the value path uses a container name filter like `containers.(name == ...)`.
4+
# This merge file corrects the default value type.
5+
app:
6+
extraVolumeMounts: []

operator/src/main/kubernetes/kubernetes.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ spec:
88
spec:
99
affinity: {}
1010
imagePullSecrets: [~]
11+
volumes: [~]
12+
containers:
13+
- name: postgresql-operator
14+
volumeMounts: [~]

operator/src/main/resources/application.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,22 @@ quarkus:
113113
paths:
114114
- (kind == Deployment).spec.template.spec.affinity
115115
description: Kubernetes affinity configuration for Pod scheduling
116+
extra-volumes:
117+
property: extraVolumes
118+
value:
119+
- null
120+
paths:
121+
- (kind == Deployment).spec.template.spec.volumes
122+
expression: "{{- if eq (toYaml .Values.app.extraVolumes | trim) \"- {}\" }} null{{- else }}{{ toYaml .Values.app.extraVolumes | nindent 8 }}{{- end }}"
123+
description: Extra volumes to add to the operator pod
124+
extra-volume-mounts:
125+
property: extraVolumeMounts
126+
value:
127+
- null
128+
paths:
129+
- (kind == Deployment).spec.template.spec.containers.(name == postgresql-operator).volumeMounts
130+
expression: "{{- if eq (toYaml .Values.app.extraVolumeMounts | trim) \"- {}\" }} null{{- else }}{{- toYaml .Values.app.extraVolumeMounts | nindent 12 }}{{- end }}"
131+
description: Extra volume mounts to add to the operator container
116132
console-color:
117133
property: envs.QUARKUS_CONSOLE_COLOR
118134
value-as-bool: ${quarkus.console.color}
@@ -130,6 +146,12 @@ quarkus:
130146
"affinity":
131147
name: app.affinity
132148
type: object
149+
"extraVolumeMounts":
150+
name: app.extraVolumeMounts
151+
type: array
152+
"extraVolumes":
153+
name: app.extraVolumes
154+
type: array
133155
expressions:
134156
release-name-labels:
135157
expression: "{{ .Release.Name }}"

operator/src/test/java/it/aboutbits/postgresql/helm/HelmTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import io.quarkus.test.junit.QuarkusTest;
77
import io.smallrye.common.process.ProcessBuilder;
88
import lombok.extern.slf4j.Slf4j;
9+
import org.assertj.core.api.InstanceOfAssertFactories;
910
import org.eclipse.microprofile.config.inject.ConfigProperty;
1011
import org.jspecify.annotations.NullMarked;
1112
import org.junit.jupiter.api.DisplayName;
@@ -92,6 +93,8 @@ void helmInstall_createsDeployment() throws IOException {
9293

9394
Objects.requireNonNull(appValues, "appValues should not be null");
9495
assertThat(appValues.get("image")).isNotNull();
96+
assertThat(appValues).containsKey("extraVolumes");
97+
assertThat(appValues).containsKey("extraVolumeMounts");
9598

9699
assertThat(chartPath.resolve("LICENSE")).exists();
97100
assertThat(chartPath.resolve("README.md")).exists();
@@ -173,9 +176,11 @@ void helmInstall_createsDeployment() throws IOException {
173176

174177
assertThat(deployment.getSpec())
175178
.isNotNull()
176-
.satisfies(spec ->
177-
assertThat(spec.getTemplate().getSpec().getImagePullSecrets()).isEmpty()
178-
);
179+
.satisfies(spec -> {
180+
assertThat(spec.getTemplate().getSpec().getImagePullSecrets()).isEmpty();
181+
assertThat(spec.getTemplate().getSpec().getVolumes()).isEmpty();
182+
assertThat(spec.getTemplate().getSpec().getContainers().getFirst().getVolumeMounts()).isEmpty();
183+
});
179184

180185
var selector = deployment.getSpec().getSelector();
181186

0 commit comments

Comments
 (0)