Resize a PersistentVolumeClaim
Kubernetes supports online expansion of PVCs backed by XFS, ext3, or ext4. Editing the PVC’s requested storage triggers the storage backend to grow the underlying disk, and the file system is expanded in place with no pod restart if the CSI driver supports it. See Expanding Persistent Volumes Claims.
PVCs can only grow — the Kubernetes API rejects shrinks.
Deployment PVCs
Section titled “Deployment PVCs”Example: resize a PVC used by a Deployment from 10 GiB to 20 GiB.
1. Preflight
Section titled “1. Preflight”-
Confirm the storage class supports expansion:
Terminal window kubectl get storageclass -o custom-columns=NAME:.metadata.name,EXPAND:.allowVolumeExpansion -
Prepare the size change in Helm / ArgoCD / whatever manages the PVC (do not merge yet).
-
Have cluster access — see k8s-oncall-setup.md.
2. Confirm the current state
Section titled “2. Confirm the current state”kubectl -n thanos describe Deployment/receive-gitlab-thanos-compactorkubectl -n thanos get pvc receive-gitlab-thanos-compactor3. Apply the change
Section titled “3. Apply the change”Merge your Helm / ArgoCD MR. The controller patches the PVC’s spec.resources.requests.storage, the backend grows the disk, and the file system expands online.
Verify:
kubectl -n thanos get pvc -l app.kubernetes.io/component=compactor -o wideStatefulSet PVCs (data-only change)
Section titled “StatefulSet PVCs (data-only change)”StatefulSet controllers do not propagate storage changes from volumeClaimTemplates to existing PVCs — see Kubernetes enhancement #661 (closed, no KEP merged). To grow only the PVC data without touching the template, patch each PVC directly.
The GCE PD CSI driver used by GKE supports online volume expansion, so no pod bounce is required — the file system grows in place while the pod continues running.
-
Find the PVCs:
Terminal window kubectl -n mimir get pvc | grep compact -
Patch each PVC’s
spec.resources.requests.storageto the new value:Terminal window kubectl -n mimir patch pvc <pvc-name> -p '{"spec":{"resources":{"requests":{"storage":"50Gi"}}}}' -
Confirm the resize completed:
Terminal window kubectl -n mimir get pvc | grep compactRarely, if the CSI driver cannot grow the volume online, the PVC gains a
FileSystemResizePendingcondition and completes on the next pod restart:- message: Waiting for user to (re-)start a pod to finish file system resize of volume on node.status: "True"type: FileSystemResizePendingBounce the pod to unblock it — for a StatefulSet, scale to 0 and back:
Terminal window kubectl -n mimir scale statefulsets/mimir-compactor --replicas=0kubectl -n mimir scale statefulsets/mimir-compactor --replicas=1
StatefulSet PVCs (template change)
Section titled “StatefulSet PVCs (template change)”Kubernetes forbids mutating a StatefulSet’s volumeClaimTemplates. Attempting to sync an ArgoCD change that modifies it is rejected as long as the StatefulSet exists. The safe path is orphan-delete: remove the StatefulSet controller but leave pods and PVCs running.
1. Prepare the change
Section titled “1. Prepare the change”Open the ArgoCD / Helm MR with the new volumeClaimTemplates size. Do not merge yet.
2. Orphan-delete the StatefulSet
Section titled “2. Orphan-delete the StatefulSet”kubectl delete statefulset <sts> -n <namespace> --cascade=orphanRepeat per StatefulSet if the workload uses one StatefulSet per zone.
Pods and PVCs keep running.
3. Resize the PVCs
Section titled “3. Resize the PVCs”NAMESPACE=<namespace>SIZE=<new-size> # e.g. 250GiSELECTOR=<label-selector> # from the StatefulSet's spec.selector.matchLabels
for pvc in $(kubectl get pvc -n "$NAMESPACE" -l "$SELECTOR" -o jsonpath='{.items[*].metadata.name}'); do kubectl patch pvc "$pvc" -n "$NAMESPACE" -p "{\"spec\":{\"resources\":{\"requests\":{\"storage\":\"$SIZE\"}}}}"doneTo find the right selector:
kubectl get statefulset <sts> -n <namespace> -o jsonpath='{.spec.selector.matchLabels}'4. Merge the MR
Section titled “4. Merge the MR”ArgoCD recreates the StatefulSet with the updated volumeClaimTemplates; pods reschedule against the already-resized PVCs.
5. Verify
Section titled “5. Verify”kubectl get statefulset <sts> -n <namespace>kubectl get pods -n <namespace> -l "$SELECTOR"kubectl get pvc -n <namespace> -l "$SELECTOR"Rollback
Section titled “Rollback”PVCs cannot be shrunk. If you have orphan-deleted the StatefulSet but not yet merged the config MR, recreate the StatefulSet manually at the original size to restore the controller. The PVC resize itself is irreversible.
Related
Section titled “Related”- Kubernetes: Expanding Persistent Volumes Claims
- GKE Storage Classes
- k8s-operations.md — general workload operations.
- alerts/kube_persistent_volume_claim_disk_space.md — PVC saturation alert.