What Are Volume Snapshots in Kubernetes?

intermediate|storagedevopssreplatform engineerCKA
TL;DR

Volume snapshots create point-in-time copies of Persistent Volumes using the CSI snapshot API. They enable backup, cloning, and disaster recovery workflows without application downtime.

Detailed Answer

Volume snapshots provide a standardized way to create point-in-time copies of Persistent Volumes in Kubernetes. They are part of the CSI (Container Storage Interface) specification and work with any CSI driver that supports snapshotting.

The Snapshot Object Model

The snapshot API mirrors the familiar PV/PVC model:

| Storage | Snapshot | |---------|----------| | StorageClass | VolumeSnapshotClass | | PersistentVolume (PV) | VolumeSnapshotContent | | PersistentVolumeClaim (PVC) | VolumeSnapshot |

Prerequisites

  1. A CSI driver that supports snapshots (e.g., aws-ebs-csi-driver, csi-driver-nfs, portworx)
  2. The snapshot controller and CRDs installed (not included by default)
# Install snapshot CRDs and controller
kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/master/client/config/crd/
kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/master/deploy/kubernetes/snapshot-controller/

Creating a VolumeSnapshotClass

apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
metadata:
  name: ebs-snapshot-class
driver: ebs.csi.aws.com
deletionPolicy: Retain
parameters:
  # Driver-specific parameters
  type: "standard"

deletionPolicy:

  • Delete: Deletes the underlying snapshot when the VolumeSnapshot is deleted
  • Retain: Keeps the snapshot even after the VolumeSnapshot object is deleted

Taking a Snapshot

apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
  name: db-snapshot-2026-03-19
  namespace: production
spec:
  volumeSnapshotClassName: ebs-snapshot-class
  source:
    persistentVolumeClaimName: postgres-data
# Check snapshot status
kubectl get volumesnapshot db-snapshot-2026-03-19 -n production
# NAME                      READYTOUSE   RESTORESIZE   AGE
# db-snapshot-2026-03-19    true         50Gi          30s

Restoring from a Snapshot

Create a new PVC with the snapshot as the data source:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: postgres-data-restored
  namespace: production
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: gp3
  resources:
    requests:
      storage: 50Gi
  dataSource:
    name: db-snapshot-2026-03-19
    kind: VolumeSnapshot
    apiGroup: snapshot.storage.k8s.io

The CSI driver creates a new volume pre-populated with the snapshot data. Mount this PVC in a Pod to access the restored data.

Cloning Volumes

You can also clone a PVC directly (without an intermediate snapshot) using the PVC as a data source:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: postgres-data-clone
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: gp3
  resources:
    requests:
      storage: 50Gi
  dataSource:
    name: postgres-data        # Source PVC
    kind: PersistentVolumeClaim

Scheduled Snapshots with CronJobs

Automate periodic snapshots with a CronJob:

apiVersion: batch/v1
kind: CronJob
metadata:
  name: daily-snapshot
  namespace: production
spec:
  schedule: "0 2 * * *"
  jobTemplate:
    spec:
      template:
        spec:
          serviceAccountName: snapshot-creator
          containers:
            - name: snapshot
              image: bitnami/kubectl:1.30
              command:
                - /bin/sh
                - -c
                - |
                  DATE=$(date +%Y-%m-%d)
                  cat <<EOF | kubectl apply -f -
                  apiVersion: snapshot.storage.k8s.io/v1
                  kind: VolumeSnapshot
                  metadata:
                    name: db-snapshot-${DATE}
                    namespace: production
                  spec:
                    volumeSnapshotClassName: ebs-snapshot-class
                    source:
                      persistentVolumeClaimName: postgres-data
                  EOF
              resources:
                requests:
                  cpu: "50m"
                  memory: "64Mi"
          restartPolicy: OnFailure

Snapshot Lifecycle

PVC (source) → VolumeSnapshot (user request)
                    ↓
              VolumeSnapshotContent (actual snapshot)
                    ↓
              New PVC (restore from dataSource)
                    ↓
              New PV (provisioned by CSI driver)

Limitations and Considerations

  1. Crash-consistent only: Snapshots capture disk state, not application state. Databases should be quiesced first.
  2. Same storage class: Restored PVCs typically must use the same storage backend as the source.
  3. Cross-namespace: VolumeSnapshots are namespace-scoped. Use VolumeSnapshotContent for cross-namespace sharing.
  4. Cost: Cloud provider snapshots incur storage costs. Implement a retention policy.
  5. Not a backup solution: Snapshots are typically stored in the same region/storage system. Use cross-region replication for disaster recovery.

Verifying Snapshot Support

# Check if your CSI driver supports snapshots
kubectl get csidriver -o jsonpath='{range .items[*]}{.metadata.name}: snapshotting={.spec.volumeLifecycleModes}{"\n"}{end}'

# List VolumeSnapshotClasses
kubectl get volumesnapshotclass

# Check snapshot status
kubectl describe volumesnapshot db-snapshot-2026-03-19

Why Interviewers Ask This

Data protection is a core responsibility for platform teams. This question tests whether you understand Kubernetes-native backup mechanisms beyond external tools.

Common Follow-Up Questions

What is the difference between VolumeSnapshot, VolumeSnapshotContent, and VolumeSnapshotClass?
VolumeSnapshot is the user request (like PVC). VolumeSnapshotContent is the actual snapshot (like PV). VolumeSnapshotClass defines the snapshot driver and parameters (like StorageClass).
Can you restore a PVC from a snapshot?
Yes — create a new PVC with dataSource referencing the VolumeSnapshot. The CSI driver provisions a new volume from the snapshot data.
Are volume snapshots application-consistent?
No — they are crash-consistent by default. For application consistency, you must freeze the application (fsfreeze) or use application-aware backup tools like Velero.

Key Takeaways

  • Volume snapshots are the Kubernetes-native way to create point-in-time copies of persistent data.
  • The snapshot API mirrors the PV/PVC model: VolumeSnapshotClass, VolumeSnapshotContent, VolumeSnapshot.
  • Snapshots are crash-consistent — use application-level quiescing for transactional consistency.

Related Questions

You Might Also Like