Free — no signup required

Volume Snapshots and Ephemeral Volumes

2 min read

Volume Snapshots

Just as you can snapshot a virtual machine disk, Kubernetes allows point-in-time copies of PVC data. This is essential for database backups, creating test environments from production data, and disaster recovery. Volume snapshots follow the same PV/PVC pattern with three analogous objects:

Snapshot Object Storage Analog Purpose
VolumeSnapshotContent PersistentVolume The actual snapshot on the storage system
VolumeSnapshot PersistentVolumeClaim User's request to create/reference a snapshot
VolumeSnapshotClass StorageClass Which CSI driver handles snapshotting

Creating a snapshot means pointing a VolumeSnapshot object at the source PVC and a snapshot class. Restoring from it is just a new PVC whose dataSource references that snapshot instead of starting empty — Kubernetes provisions the new volume pre-populated with the snapshot's data. Volume snapshots require the CSI driver to support the snapshot capability and the VolumeSnapshot CRDs to be installed in the cluster. Not all CSI drivers support snapshots — check your driver's documentation.

Ephemeral Volumes

Not all storage needs to be permanent. Kubernetes provides several ephemeral volume types for temporary data:

emptyDir — A scratch directory created when a Pod is assigned to a node. It starts empty (hence the name). Data survives container crashes within the same Pod (because the Pod is still on the node), but is deleted when the Pod is removed from the node for any reason. Common uses: temporary caches, sharing files between containers in the same Pod, scratch space for batch jobs. It can optionally be backed by RAM (tmpfs) instead of disk, with a size cap, for maximum speed.

ConfigMap and Secret mounts — Configuration data and secrets can be projected into the container filesystem as files. This is how you inject TLS certificates, configuration files, or API keys without baking them into the container image — with file permissions on a mounted Secret typically locked down to owner-read-only for security.

projected — Combines multiple volume sources (ConfigMap, Secret, ServiceAccountToken, DownwardAPI) into a single directory. Useful when an application expects all its configuration in one place.

The key distinction: ephemeral volumes are tied to the Pod lifecycle, not the PVC lifecycle. When the Pod dies, the data dies with it. Use them for data you can afford to lose — caches, temp files, injected config — never for data you need to keep.

This is one of 18 chapters

Every chapter is free — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

Sign up free