Skip to content

Add extraVolumes and extraVolumeMounts Helm values for mounting files into the operator pod - #65

Closed
fredordercloud wants to merge 2 commits into
aboutbits:mainfrom
ordercloud:feature/volume-mount-heml-chart
Closed

Add extraVolumes and extraVolumeMounts Helm values for mounting files into the operator pod#65
fredordercloud wants to merge 2 commits into
aboutbits:mainfrom
ordercloud:feature/volume-mount-heml-chart

Conversation

@fredordercloud

Copy link
Copy Markdown
Contributor

Summary

  • Add extraVolumes and extraVolumeMounts Helm values for mounting files into the operator pod
  • Enables adminSecretFileRef usage without patching the deployment
  • Includes workaround for quarkus-helm bug (generates {} instead of [] for container-scoped paths)

Test plan

  • ./gradlew :operator:test --tests "it.aboutbits.postgresql.helm.HelmTest"
  • Default install: no volumes, no volumeMounts

@ThoSap ThoSap self-assigned this Sep 4, 2026

@ThoSap ThoSap left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry but I have to close this, I told you in PR #60 that we will do this in a follow-up PR.

Your version actually uses the old workaround for Helm chart values.yaml, I changed that in PR #62.

I opened #62 two hours before this PR, for the same gap, and it carries wider test coverage, and it also moves imagePullSecrets onto the same new pattern we used instead of the workaround you carried on.

I also decided against using extraVolumes and extraVolumeMounts, which matches the convention of Bitnami charts.
The reason is that extra implies that the Deployment has already a volume on it, which is not the case with our operator.

So volumes and volumeMounts match the rest of this chart, where imagePullSecrets and affinity use the raw Kubernetes names.

value:
- null
paths:
- (kind == Deployment).spec.template.spec.containers.(name == postgresql-operator).volumeMounts

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The container name is hardcoded here. We should use ${quarkus.kubernetes.name} instead.

Five other paths in this file already do, including line 86 and lines 99 to 109.

A change to quarkus.kubernetes.name breaks this path silently. quarkus-helm finds no node, processValueReference does nothing, and the value never reaches the template. No build error, no test failure, just a chart that ignores extraVolumeMounts.

# when the value path uses a container name filter like `containers.(name == ...)`.
# This merge file corrects the default value type.
app:
extraVolumeMounts: []

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

extraVolumes needs the same override.

This file corrects extraVolumeMounts only. I built your branch and read the generated chart:

app:
  extraVolumeMounts: []
  extraVolumes:
    - {}
  imagePullSecrets:
    - {}

So helm show values presents extraVolumes as - {}. A user who copies that block and appends a volume name ships an invalid first entry. The guard expression keeps the default install correct, so nothing breaks until a user edits the value. That is the worst moment for it to break.


Objects.requireNonNull(appValues, "appValues should not be null");
assertThat(appValues.get("image")).isNotNull();
assertThat(appValues).containsKey("extraVolumes");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

containsKey passes on the broken default. extraVolumes is [{}] in the built chart, and this assertion still passes.

assertThat(appValues.get("extraVolumes")).isEqualTo(List.of());

Two further gaps in this test:

  • Nothing asserts type: array and the description in values.schema.json. A missing type falls back to string, and then helm install rejects a list.
  • Nothing renders the chart with a real volume. helm template needs no cluster, and it validates the values against the schema. A wrong nindent produces invalid YAML for every user who sets the value, and no current test sees that.

.satisfies(spec -> {
assertThat(spec.getTemplate().getSpec().getImagePullSecrets()).isEmpty();
assertThat(spec.getTemplate().getSpec().getVolumes()).isEmpty();
assertThat(spec.getTemplate().getSpec().getContainers().getFirst().getVolumeMounts()).isEmpty();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

getFirst() hides the risk that the named container introduces.

kubernetes.yml now names a container. If that name ever stops matching quarkus.kubernetes.name, the Pod gets two containers, and getFirst() may still return the right one. A fix would look like this:

assertThat(spec.getTemplate().getSpec().getContainers())
        .singleElement()
        .satisfies(container -> {
            assertThat(container.getName()).isEqualTo("postgresql-operator");
            assertThat(container.getVolumeMounts()).isEmpty();
        });

> **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:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Missing Secrets Store CSI example.

@ThoSap

ThoSap commented Sep 4, 2026

Copy link
Copy Markdown
Member

Duplicate of #62

@ThoSap ThoSap marked this as a duplicate of #62 Sep 4, 2026
@ThoSap ThoSap closed this Sep 4, 2026
@ThoSap ThoSap removed their assignment Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants