Skip to content

feat: add custom labels to storage PVCs - #239

Merged
guerzon merged 5 commits into
guerzon:mainfrom
guarnz:feat/pvc-labels
Aug 7, 2026
Merged

feat: add custom labels to storage PVCs#239
guerzon merged 5 commits into
guerzon:mainfrom
guarnz:feat/pvc-labels

Conversation

@guarnz

@guarnz guarnz commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Adds support for setting custom labels on the storage PVCs (storage.data and storage.attachments), rendered on the volumeClaimTemplates of the StatefulSet.

Why

Some controllers select PersistentVolumeClaims by label, not by annotation or pod. My use case is Longhorn's backup automation: a Longhorn RecurringJob runs backups against the volumes that carry a specific label — there is no annotation or pod-based alternative for this. See the docs:

  • RecurringJob — jobs act on volumes grouped by the label recurring-job-group.longhorn.io/<group>.

Today the chart hardcodes the PVC labels (only the app.kubernetes.io/* set), so there is no way to add such a selector label from values. The only workarounds are storage.existingVolumeClaim (manage the PVC yourself) or a manual kubectl label, both of which break the GitOps flow.

Custom PVC labels are useful beyond this single case — e.g. selecting volumes for other backup/snapshot operators (Velero, Kanister) that also act on volumes by label.

Changes

  • templates/_pvcSpec.tpl: render storage.data.labels and storage.attachments.labels on the respective volumeClaimTemplates, merged after the existing app.kubernetes.io/* labels
  • values.yaml: document the new optional labels key under storage.data and storage.attachments
  • Chart.yaml: version bump 0.43.1 → 0.44.0 (minor; new feature)
  • README regenerated (no parameter-table change: storage.data/storage.attachments are documented as dictionaries)

Notes

  • Backwards compatible: with no labels set, the rendered output is unchanged.
  • Since volumeClaimTemplates are immutable on an existing StatefulSet, labels apply to newly provisioned PVCs (same as the existing PVC fields).

Example

storage:
  data:
    name: vaultwarden-data
    size: 5Gi
    accessMode: ReadWriteOnce
    labels:
      recurring-job-group.longhorn.io/backup: enabled

Signed-off-by: nieri0x73 <122804277+nieri0x73@users.noreply.github.com>

@santiagon610 santiagon610 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 🚀

guarnz added 3 commits August 7, 2026 10:33
Signed-off-by: Ricardino Guarnieri <122804277+guarnz@users.noreply.github.com>

# Conflicts:
#	charts/vaultwarden/Chart.yaml
…abels

Signed-off-by: Ricardino Guarnieri <122804277+guarnz@users.noreply.github.com>

# Conflicts:
#	charts/vaultwarden/Chart.yaml
@guerzon

guerzon commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Hi @guarnz 😊,

Please:

Signed-off-by: Ricardino Guarnieri <122804277+guarnz@users.noreply.github.com>
@guarnz

guarnz commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Hi @guerzon, thanks for the review! 😊

Bumped the chart version to 0.46.0.
Ran generate-readme.sh — no changes were produced.
Added documentation to the "Persistent storage" section.

@guerzon
guerzon merged commit 6f8cf59 into guerzon:main Aug 7, 2026
1 check passed
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.

3 participants