Pro ยท Lesson 6 of 12
A Pod's disk disappears with the Pod unless you asked for a volume that outlives it. A StatefulSet is for pods that need stable names.
Sign in to save your place.
emptyDir is a backpack the boat throws away when it sinks. A PersistentVolumeClaim is a locker with a number. A StatefulSet gives each boat the same name and the same locker when it is rebuilt.
emptyDir lasts for the life of the Pod. It is fine for a cache. hostPath mounts the node's disk. It pins you to that node and is a sharp tool on a shared cluster. A PersistentVolumeClaim asks a StorageClass for a volume. The CSI driver, not Kubernetes itself, talks to the disk system.
ReadWriteOnce, ReadWriteMany, and the newer access modes depend on the driver. A claim the driver cannot satisfy stays Pending. That is a storage problem, not a YAML typo, once the class name is right.
| Volume | Survives a new Pod? | Typical use |
|---|---|---|
| emptyDir | No | Scratch space |
| hostPath | Only on that same node | Avoid on multi-tenant clusters |
| PVC | Yes, if the reclaim policy keeps it | Databases and queues |
A StatefulSet gives Pods stable names: db-0, db-1. It creates volumes from volumeClaimTemplates so each ordinal can keep its own disk. Startup and rolling replacement are ordered unless you change the policy.
A StatefulSet does not make a database highly available by itself. Replication, failover, and backups are the database's job. The workload object only gives you stable identity and disks.
Step 1 of 3The scratch disk is deleted with the Pod.
Step 2 of 3The claim can be mounted again by the next Pod, if the access mode and node allow it.
Step 3 of 3Ordinal 0 comes back as db-0 and can see the same claim.
Write a file in a Pod, delete the Pod, and start another with the same image. The file should be gone. Do not use hostPath for this lab.
kubectl run scratch --image=busybox:1.36 --restart=Never --command -- sh -c 'echo hello > /tmp/note && sleep 3600'
kubectl exec scratch -- cat /tmp/note
kubectl delete pod scratch --wait=false
# a new Pod with the same image will not have /tmp/note
Checked against the linked documentation in October 2026. A later release can move a flag, a price, or a supported pair. Use the page for the version you installed.