Volumes, PVCs, and Storage Classes
SummaryThis chapter covers why Pods need persistent storage,...
This chapter covers why Pods need persistent storage,...
This chapter covers why Pods need persistent storage, the ephemeral nature of container filesystems, Kubernetes volume types (emptyDir, hostPath, configMap, secret, projected), PersistentVolumes, PersistentVolumeClaims, access modes, StorageClasses, and dynamic provisioning. Three hands-on exercises reinforce PVC creation, multi-container volume sharing, and reclaim policy behavior.
Volumes, PVCs, and Storage Classes
Every container you have deployed so far has had a dirty secret: its filesystem is a throwaway. When a container restarts — whether because of a crash, a liveness probe failure, or a rolling update — the replacement container starts with a clean image. Every file the previous container wrote is gone. Log entries, uploaded files, database records, cached computations — all of it vanishes.
For stateless applications, this is a feature, not a bug. A web server that reads its configuration from a ConfigMap and serves responses from memory has no reason to care about filesystem persistence. But the moment an application needs to store data that survives beyond a single container’s lifetime — user uploads, SQLite databases, machine learning checkpoints, message queue buffers — you need Kubernetes storage.
The Storage Domain on the CKAD
The CKAD exam allocates 8% of its total score to the “Application Environment, Configuration & Security” domain, which includes storage. In practice, you can expect one to two tasks that require creating PersistentVolumeClaims, mounting volumes in Pods, or working with StorageClasses. These tasks are not conceptually difficult, but they require precise YAML — a wrong accessMode, a missing mountPath, or a mismatched storageClassName will cost you points and, worse, cost you time debugging.
What You Will Learn
This chapter builds your understanding of Kubernetes storage in two layers:
Section 1: Volume Types and PersistentVolume Lifecycle covers the fundamental question of how data gets attached to Pods. You will learn the difference between ephemeral volumes (emptyDir, hostPath) and persistent volumes (PV/PVC), the lifecycle that governs how storage moves between states, and how static and dynamic provisioning work.
Section 2: PVCs, Access Modes, and Storage Classes focuses on the resources you will create most often — PersistentVolumeClaims and StorageClasses. You will learn access mode semantics (RWO, ROX, RWX, RWOP), how to mount a PVC in a Pod, how dynamic provisioning eliminates the need for manual PV creation, and how Kind’s default StorageClass works. The section ends with three exercises that cover the most likely exam scenarios.
By the end of this chapter, you will be able to provision storage, mount it in Pods, and predict what happens when a PVC is deleted — all without hesitation.