Skip to content

Commit

Permalink
Delete PVCs when stateful set is deleted
Browse files Browse the repository at this point in the history
Add PVC retention policy[1] to delete the PVCs when the statesfulset is
deleted. Retain PVCs when scaling down so we can scale up again without
loosing data.

[1] https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#persistentvolumeclaim-retention

Signed-off-by: Nir Soffer <[email protected]>
  • Loading branch information
nirs committed Nov 13, 2023
1 parent c31943b commit b0b2dd2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions busybox-statefulset/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ kind: StatefulSet
metadata:
name: busybox
spec:
# Required for proper clean up on failover and successful relocate. You
# must enable the StatefulSetAutoDeletePVC feature gate for this.
# https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#persistentvolumeclaim-retention
persistentVolumeClaimRetentionPolicy:
whenDeleted: Delete
whenScaled: Retain
selector:
matchLabels:
appname: busybox
Expand Down

0 comments on commit b0b2dd2

Please sign in to comment.