Volumes, PersistentVolumes and Stateful Apps
Know how Kubernetes separates storage requests (PVCs) from storage (PVs), how StorageClasses provision volumes, and how access modes, binding mode and reclaim policy decide where data lives and when it is deleted.
Key points
- 1
emptyDir lives as long as the Pod on its node and survives container restarts;
medium: Memoryis a tmpfs that counts against the container memory limit. - 2
PVs are cluster-scoped; PVCs are namespaced requests that bind one-to-one to a PV with the same class, enough capacity and the requested access modes.
- 3
ReadWriteOnce is per node, ReadWriteOncePod is per Pod, and ReadWriteMany needs a shared filesystem such as NFS or EFS.
- 4
Dynamic PVs default to
reclaimPolicy: Delete: deleting the PVC deletes the disk. Use Retain and backups for important data. - 5
WaitForFirstConsumerprovisions after scheduling, avoiding zone and node conflicts; local volumes require it. - 6
StatefulSets create one PVC per ordinal (
<template>-<sts>-<ordinal>), kept on scale-down unlesspersistentVolumeClaimRetentionPolicysays otherwise. - 7
Volumes can grow (with
allowVolumeExpansion) but never shrink; snapshots restore through a PVCdataSource.
Common traps
storageClassName: ""disables dynamic provisioning; omitting the field uses the default class.A single-replica Deployment with an RWO disk and RollingUpdate deadlocks on Multi-Attach; use Recreate or a StatefulSet.
CSI snapshots are crash-consistent, not application-consistent; databases need quiescing or native backups.
Read the source
Test yourself on Volumes, PersistentVolumes and Stateful Apps
Ten questions, with the answer and explanation after each one.