Skip to content

Commit db11b93

Browse files
ThoSapclaude
andcommitted
Add volumes and volumeMounts values to the Helm chart for file-based credentials
Follow-up to #60. The chart now exposes `app.volumes` and `app.volumeMounts`, so a user of the published chart can mount a credentials file for `adminSecretFileRef` through `values.yaml`. `app.imagePullSecrets` moves onto the same pattern and loses its `- {}` default. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 971582e commit db11b93

6 files changed

Lines changed: 305 additions & 11 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
### PostgreSQL Operator ###
22
config/
3+
# Written by the fabric8 Kubernetes client when the tests run against the Dev Service
4+
.kube/
35

46
### STS ###
57
.apt_generated

docs/cluster-connection.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,63 @@ 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+
##### With the Helm chart
79+
80+
The chart exposes the `app.volumes` and `app.volumeMounts` values. Both take the raw Kubernetes syntax, so any volume source works. Pass them in your own values file:
81+
82+
```yaml
83+
app:
84+
volumes:
85+
- name: db-credentials
86+
secret:
87+
secretName: db-credentials-secret
88+
volumeMounts:
89+
- name: db-credentials
90+
mountPath: /mnt/secrets
91+
readOnly: true
92+
```
93+
94+
```bash
95+
helm install postgresql-operator <chart-url> --values values.yaml
96+
```
97+
98+
See the [installation section](../README.md#helm-chart) of the README for the chart URL.
99+
100+
##### With the Secrets Store CSI driver
101+
102+
Use this option to read the credentials from an external secret store, for example AWS Secrets Manager. The chart does not create the `SecretProviderClass`, so you have to apply it yourself:
103+
104+
```yaml
105+
apiVersion: secrets-store.csi.x-k8s.io/v1
106+
kind: SecretProviderClass
107+
metadata:
108+
name: db-credentials
109+
spec:
110+
provider: aws
111+
parameters:
112+
objects: |
113+
- objectName: "my/db/credentials"
114+
objectAlias: "db-credentials.json"
115+
```
116+
117+
Then reference it from the chart values:
118+
119+
```yaml
120+
app:
121+
volumes:
122+
- name: db-credentials
123+
csi:
124+
driver: secrets-store.csi.k8s.io
125+
readOnly: true
126+
volumeAttributes:
127+
secretProviderClass: db-credentials
128+
volumeMounts:
129+
- name: db-credentials
130+
mountPath: /mnt/secrets
131+
readOnly: true
132+
```
133+
134+
> **Note:** The `SecretProviderClass` must live in the namespace of the operator.
79135

80136
### Examples
81137

operator/src/main/helm/values.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
# This file overrides the default values that the quarkus-helm extension generates.
3+
#
4+
# Why it exists: a list field of the operator Deployment becomes a Helm value only if the key
5+
# already exists in `src/main/kubernetes/kubernetes.yml`. An empty list `[]` does not survive
6+
# there. The fabric8 model marks `PodSpec.imagePullSecrets`, `PodSpec.volumes` and
7+
# `Container.volumeMounts` with `@JsonInclude(NON_EMPTY)`. A list with one null element does
8+
# survive, but the generated default then reads `- {}`. That is not a usable default, so this
9+
# file replaces it with a real empty list.
10+
#
11+
# See https://github.com/quarkiverse/quarkus-helm/issues/453
12+
app:
13+
imagePullSecrets: []
14+
volumes: []
15+
volumeMounts: []

operator/src/main/kubernetes/kubernetes.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,10 @@ spec:
77
template:
88
spec:
99
affinity: {}
10+
# The `[~]` placeholders are required, see operator/src/main/helm/values.yaml for the reason.
1011
imagePullSecrets: [~]
12+
volumes: [~]
13+
containers:
14+
# The name must match `quarkus.kubernetes.name`, otherwise Dekorate adds a second container.
15+
- name: postgresql-operator
16+
volumeMounts: [~]

operator/src/main/resources/application.yml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,9 @@ quarkus:
8686
- (kind == Deployment).spec.template.spec.containers.(name == ${quarkus.kubernetes.name}).imagePullPolicy
8787
image-pull-secrets:
8888
property: imagePullSecrets
89-
value:
90-
- null
9189
paths:
9290
- (kind == Deployment).spec.template.spec.imagePullSecrets
93-
expression: "{{- if eq (toYaml .Values.app.imagePullSecrets | trim) \"- {}\" }} null{{- else }}{{- toYaml .Values.app.imagePullSecrets | nindent 8 }}{{- end }}"
94-
description: Kubernetes image pull secrets to use if the OCI image is hosted on a private registry
91+
expression: "{{- toYaml (.Values.app.imagePullSecrets | default list) | nindent 8 }}"
9592
resource-requests-cpu:
9693
property: resources.requests.cpu
9794
value: ${quarkus.kubernetes.resources.requests.cpu}
@@ -113,6 +110,16 @@ quarkus:
113110
paths:
114111
- (kind == Deployment).spec.template.spec.affinity
115112
description: Kubernetes affinity configuration for Pod scheduling
113+
volumes:
114+
property: volumes
115+
paths:
116+
- (kind == Deployment).spec.template.spec.volumes
117+
expression: "{{- toYaml (.Values.app.volumes | default list) | nindent 8 }}"
118+
volume-mounts:
119+
property: volumeMounts
120+
paths:
121+
- (kind == Deployment).spec.template.spec.containers.(name == ${quarkus.kubernetes.name}).volumeMounts
122+
expression: "{{- toYaml (.Values.app.volumeMounts | default list) | nindent 12 }}"
116123
console-color:
117124
property: envs.QUARKUS_CONSOLE_COLOR
118125
value-as-bool: ${quarkus.console.color}
@@ -127,9 +134,26 @@ quarkus:
127134
description: Specify the format of the produced JSON. Supported values are "DEFAULT", "ECS", and "GCP".
128135
values-schema:
129136
properties:
137+
# The type must be set explicitly for every non-scalar value, because the generated
138+
# schema otherwise falls back to `string`.
139+
#
140+
# A value that `src/main/helm/values.yaml` provides also loses the `description` of its
141+
# `quarkus.helm.values` entry, so the description belongs here instead.
130142
"affinity":
131143
name: app.affinity
132144
type: object
145+
"imagePullSecrets":
146+
name: app.imagePullSecrets
147+
type: array
148+
description: Kubernetes image pull secrets to use if the OCI image is hosted on a private registry
149+
"volumes":
150+
name: app.volumes
151+
type: array
152+
description: Additional volumes for the operator Pod, for example a Secret volume or a Secrets Store CSI volume
153+
"volumeMounts":
154+
name: app.volumeMounts
155+
type: array
156+
description: Additional volume mounts for the operator container
133157
expressions:
134158
release-name-labels:
135159
expression: "{{ .Release.Name }}"

0 commit comments

Comments
 (0)