Volumes and Persistence
Why Storage Matters
Picture a chef preparing meals in a busy kitchen. Ingredients (data) are stored in the pantry, but if the pantry disappears every time the chef leaves, chaos ensues. Kubernetes pods face the same challenge: pods are ephemeral - they can be destroyed and recreated at any time. Without persistent storage, critical data would vanish.
To solve this, Kubernetes introduced Volumes and Persistent Volumes (PVs) - the pantries and warehouses of Kubernetes, ensuring data survives beyond the lifecycle of pods.
Volumes
Local Pantries for Pods
- Definition: A Volume is a storage abstraction attached to a pod.
- Lifecycle: Volumes live as long as the pod, but can outlast individual containers inside it.
- Types:
- emptyDir: Temporary storage, wiped when the pod is deleted.
- hostPath: Maps a directory from the node’s filesystem.
- configMap/secret volumes: Inject configuration or sensitive data into pods.
- Analogy: Volumes are like kitchen pantries - containers (chefs) can share ingredients while cooking.
Persistent Volumes
Warehouses for Clusters
- Definition: A Persistent Volume (PV) is a cluster‑wide storage resource, independent of pods.
- Lifecycle: PVs exist beyond pod lifetimes, ensuring data durability.
- Provisioning: PVs can be statically created by admins or dynamically provisioned via StorageClasses.
- Use Case: Databases, file storage, or any workload requiring long‑term persistence.
- Analogy: PVs are like warehouses - data stays safe even if chefs (pods) come and go.
Persistent Volume Claims
The Access Keys
- Definition: A Persistent Volume Claim (PVC) is a request for storage by a pod.
- Binding: PVCs bind to PVs that match their requirements (size, access mode).
- Analogy: PVCs are like warehouse keys—pods request access, and Kubernetes ensures they get the right storage.
Global Context
- Enterprises: Use PVs and PVCs to run stateful workloads like databases and analytics pipelines.
- Cloud Providers: AWS EBS, Azure Disks, and GCP Persistent Disks integrate seamlessly with Kubernetes PVs.
- Community: Persistent storage is a cornerstone of Kubernetes, enabling stateful applications at scale.
Hands‑On Exercise
- Reflect: How do PVs and PVCs ensure data survives beyond pod lifecycles?
Attach PVC to a pod:
apiVersion: v1
kind: Pod
metadata:
name: pod-demo
spec:
containers:
- name: app
image: nginx
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: storage
volumes:
- name: storage
persistentVolumeClaim:
claimName: pvc-demo
Create a Persistent Volume Claim:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-demo
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
Create a Persistent Volume:
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-demo
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /data/pv-demo
The Hacker’s Notebook
- Volumes are pantries - shared storage for pods.
- Persistent Volumes are warehouses - durable storage across clusters.
- PVCs are keys - granting pods access to the right warehouse.
- Lesson for engineers: Stateless apps are easy, but stateful apps need persistence.
- Hacker’s mindset: Treat storage as your backbone. With PVs and PVCs, you can run databases, analytics, and global apps confidently.

Updated on Dec 29, 2025