Volume snapshots, expansion and stateful data
Day-two operations on persistent data: growing a claim, recovering from a failed resize, CSI snapshots and group snapshots, cloning, and what a snapshot is not.
Volume snapshots, expansion and stateful data
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- To grow a volume, raise the claim's storage request. It only works for dynamically provisioned claims whose class sets allowVolumeExpansion, and volumes never shrink.
- Expansion is a controller step (the external-resizer grows the disk) and often a node step (the kubelet grows the filesystem). Since 1.34 you can lower a failed request back toward the real capacity.
- VolumeSnapshot, VolumeSnapshotContent and VolumeSnapshotClass mirror PVC, PV and StorageClass. They are CRDs plus a snapshot controller, and the CSI driver does the work.
- A claim restores from a snapshot or clones another claim through dataSource. VolumeGroupSnapshot (GA in 1.36) captures several claims at one point in time.
- Snapshots are crash-consistent copies that usually live in the same storage system. They aren't application-consistent and aren't an off-site backup on their own.
Running data, not just storing it
Getting a database onto a dynamically provisioned volume is day one. Day two brings different questions. The disk is 90 percent full: can it grow without downtime? You’re about to run a risky schema migration: can you take a restore point first? QA wants a copy of production data: can you clone it without a dump and reload? Before Kubernetes, each of those was a ticket to the storage team or a console session. Kubernetes turns them into API objects that a CSI driver carries out.
Growing a volume
To expand, raise the request on the claim:
kubectl patch pvc pgdata -p '{"spec":{"resources":{"requests":{"storage":"40Gi"}}}}'
Two conditions apply, and the API server enforces both. The claim must be dynamically provisioned by a class with allowVolumeExpansion: true. A statically bound claim on our lab cluster was refused with only dynamically provisioned pvc can be resized and the storageclass that provisions the pvc must support resize. And volumes never shrink: asking for less than the current capacity failed with field can not be less than status.capacity.
Expansion is usually two steps. The controller step grows the disk: the CSI driver’s external-resizer sees the new request and calls ControllerExpandVolume. Our claim, with no driver installed, got the event ExternalExpanding: waiting for an external controller to expand this PVC and stayed there. The node step grows the filesystem inside the disk: the kubelet calls the driver’s NodeExpandVolume on the node where it’s mounted. Most drivers do both online, with the Pod running. status.capacity changes when it’s done, and status.allocatedResources shows what’s been allocated along the way.
Sometimes expansion fails. You ask for 1Ti and the backend’s quota allows 500Gi. Recovery from a failed expansion went GA in 1.34: you may lower the request again, to anything still at or above status.capacity. We set our claim back from 40Gi to 30Gi while its capacity was 20Gi, and it was accepted. The resizer then retries with the smaller size. Quota is charged on the larger of the request and what’s allocated, so you can’t game it this way.
Snapshots
Snapshots copy the same pattern you already know from claims:
| Claims | Snapshots |
|---|---|
| StorageClass | VolumeSnapshotClass |
| PersistentVolumeClaim (namespaced request) | VolumeSnapshot |
| PersistentVolume (the real thing) | VolumeSnapshotContent |
They aren’t in core Kubernetes. They’re CRDs plus a snapshot controller from the kubernetes-csi/external-snapshotter project (v8.7 as of November 2026), plus the driver’s csi-snapshotter sidecar. Managed clusters usually install them. We applied the v8.7.1 CRDs, which serve all six snapshot and group-snapshot kinds at v1, and created:
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
metadata: {name: ebs-snap}
driver: ebs.csi.aws.com
deletionPolicy: Retain
---
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata: {name: pgdata-before-upgrade, namespace: storage}
spec:
volumeSnapshotClassName: ebs-snap
source: {persistentVolumeClaimName: pgdata}
With a controller and driver, the snapshot gets a VolumeSnapshotContent pointing at the real backend snapshot, and READYTOUSE turns true. In our lab nothing processed it, so the columns stayed empty. That’s what a missing snapshot controller looks like. deletionPolicy: Retain keeps the backend snapshot even if someone deletes the VolumeSnapshot object, a sensible default for restore points.
Restoring and cloning
A new claim can start pre-filled, from a snapshot or from another claim, through dataSource:
apiVersion: v1
kind: PersistentVolumeClaim
metadata: {name: pgdata-restore, namespace: storage}
spec:
accessModes: [ReadWriteOnce]
storageClassName: gp3
resources: {requests: {storage: 20Gi}}
dataSource:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
name: pgdata-before-upgrade
Use kind: PersistentVolumeClaim, name: pgdata to clone a live claim instead, within one namespace and one driver. The API server mirrored our dataSource into dataSourceRef, the newer field that also accepts custom volume populators, controllers that fill a new volume from any source, such as an object-storage backup.
To roll a database back, you don’t rewind its volume in place. You restore into a new claim and point the workload at it: a StatefulSet’s volumeClaimTemplates names claims by convention, so you swap the claim behind each replica. That’s fiddly, which is one reason database operators exist.
What a snapshot isn’t
A snapshot is crash-consistent: the disk exactly as it was at one instant, as if the power had been cut. Databases with write-ahead logs recover from that fine. Two cases need more:
- Several volumes. A database with data on one volume and logs on another, snapshotted a second apart, may be inconsistent. A VolumeGroupSnapshot, GA since 1.36, selects claims by label and snapshots them at one point in time, if the driver supports it.
- Application consistency. Flushing buffers and pausing writes first, using
fsfreeze, pre-snapshot hooks in tools like Velero, or the database’s own backup mode.
And a snapshot usually lives in the same storage system, account and region as the volume. It protects against bad migrations and fat-fingered deletes, not against losing the account or region. Real backups copy data elsewhere. Velero, Kasten and database-native tools (CloudNativePG’s backups to object storage, for example) do that, and incremental backup tools are starting to use CSI changed block tracking, now beta, to copy only the blocks that changed. The backup and disaster recovery lesson covers the cluster side.
About the video
The embed is Beyond the README’s “Kubernetes Volume Snapshots”, July 2023, 13 minutes. Its chapters cover snapshot background, how PersistentVolumes and volume snapshots relate, an environment setup, a worked example that inspects the underlying storage, taking the snapshot, inspecting the snapshot in storage, and creating a PersistentVolume from it. That’s the snapshot half of this lesson, shown end to end with a real driver. It doesn’t cover expansion, failure recovery or group snapshots. Judged from chapters and description, since transcripts can’t be fetched here. It has no audio-track flag and an English caption track. Mischa van den Burg’s CloudNativePG course in deeper shows how an operator handles storage, backups and rescheduling for Postgres.
What was run: against a local v1.37.3 control plane with no CSI driver or snapshot controller, we expanded a dynamically provisioned claim, hit the static-claim and shrink errors, lowered a pending expansion within the recovery rule, installed external-snapshotter v8.7.1’s CRDs, and created the VolumeSnapshotClass, VolumeSnapshot, a restore claim and a clone claim, seeing dataSourceRef mirrored. Nothing was actually resized, snapshotted or restored. Those steps are from the Kubernetes storage docs and the v1.36 group-snapshot and changed-block-tracking blog posts, checked 2026-11-28.
Where this fits
Storage done. Next, how the cluster decides how much CPU and memory each Pod gets, and where it runs. Next: requests, limits and QoS classes.
Check yourself
You raise a claim from 20Gi to 40Gi. The event says 'waiting for an external controller to expand this PVC' and nothing happens. What is missing?
The CSI driver's controller with its external-resizer sidecar, or a driver that supports expansion. Kubernetes only records the new request. If the disk grows but the size seen in the Pod doesn't, the node-side filesystem resize hasn't run yet, which happens when the kubelet next mounts or processes the volume.
An expansion to 1Ti fails because the storage backend's quota is 500Gi. Can you undo it?
Since 1.34, yes: lower spec.resources.requests.storage to any value still at or above status.capacity, such as 400Gi, and the resizer retries with that. Before that feature you were stuck with a claim that would keep retrying the impossible size.
You snapshot a running PostgreSQL volume and restore it. Postgres starts and replays its WAL. Why, and when is that not good enough?
The snapshot is crash-consistent, the same as pulling the power: Postgres recovers from its write-ahead log. It isn't good enough when an app spreads state across volumes snapshotted at different moments, or doesn't recover cleanly from a crash. Use group snapshots, or quiesce the app (pre-snapshot hooks, or the database's own backup tool).
Your only backups are VolumeSnapshots of EBS volumes in the same account. What risk remains?
Snapshots usually live in the same storage system, account and region. Deleting the account, a region outage or a ransomware actor with the same credentials can take the volumes and snapshots together. Copy backups off-site, for example with Velero or the database's own backups to object storage in another account.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.