Skip to content

refactor(app): use StatefulSet for persistence instead of standalone PVCs#10

Merged
robinbraemer merged 1 commit into
mainfrom
robin/refactor-persistence-to-statefulset
Mar 11, 2026
Merged

refactor(app): use StatefulSet for persistence instead of standalone PVCs#10
robinbraemer merged 1 commit into
mainfrom
robin/refactor-persistence-to-statefulset

Conversation

@robinbraemer

Copy link
Copy Markdown
Member

Summary

  • Persistence disabled → renders Deployment (stateless, any replica count)
  • Persistence enabled → renders StatefulSet with volumeClaimTemplates (per-pod PVCs, stable identity)
  • Extract shared pod template into _helpers.tpl (app.podTemplate) to avoid duplication
  • Delete pvc.yaml — StatefulSet manages PVC lifecycle automatically
  • Bump chart version to 1.2.0

This is the idiomatic K8s pattern: StatefulSet creates a unique PVC per pod replica (e.g. data-myapp-0, data-myapp-1), so scaling with ReadWriteOnce works correctly. ArgoCD with pruning will handle the Deployment → StatefulSet transition.

Follows up on #9.

Test plan

  • helm lint app/ passes
  • helm template without persistence renders Deployment (no StatefulSet)
  • helm template with persistence renders StatefulSet with volumeClaimTemplates (no Deployment)
  • Multiple volumes produce multiple volumeClaimTemplates + volumeMounts
  • storageClassName omitted when not specified
  • Integration test in cnap repo passes after chart release

Replace standalone PVC + Deployment approach with conditional resource:
- persistence disabled → Deployment (stateless, any replica count)
- persistence enabled → StatefulSet with volumeClaimTemplates (per-pod PVCs)

Extract shared pod template into _helpers.tpl to avoid duplication.
Delete pvc.yaml — StatefulSet manages PVC lifecycle automatically.

Bump chart version to 1.2.0.
@robinbraemer
robinbraemer merged commit 39eac65 into main Mar 11, 2026
2 checks passed
@robinbraemer
robinbraemer deleted the robin/refactor-persistence-to-statefulset branch March 17, 2026 09:03
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.

1 participant