Memory hook: A volume is mounted, a claim asks, a PV supplies, a StorageClass provisions.
Must remember
- The writable layer of a container is disposable. A volume exposes storage to containers in a Pod. Containers share the volume only when each mounts it; their independent root filesystems are not automatically shared.
- emptyDir starts empty when a Pod is assigned to a node. It survives individual container restarts within that Pod but is removed when the Pod is removed from the node. Use it for scratch data or cooperation between containers, not the only copy of important records.
- A PersistentVolume, PV, represents a storage resource in the cluster. A PersistentVolumeClaim, PVC, is a namespaced request for storage with requirements such as capacity and access mode. A Pod mounts a claim; the claim binds to suitable storage.
- Static provisioning supplies an existing PV. Dynamic provisioning uses a StorageClass and provisioner to create backing storage for a suitable claim. CSI provides an integration standard between Kubernetes and storage systems.
- A PV is cluster-scoped; a PVC is namespaced. The workload and its claim normally belong to the same namespace. Persistent storage has a lifecycle separate from an individual Pod, but its survival still depends on deletion and reclaim settings.
| Access mode | Meaning to remember |
|---|---|
| ReadWriteOnce, RWO | Read-write mounting from one node; several Pods on that node may use it |
| ReadOnlyMany, ROX | Read-only mounting from multiple nodes |
| ReadWriteMany, RWX | Read-write mounting from multiple nodes |
| ReadWriteOncePod, RWOP | Read-write mounting by one Pod, with supported CSI storage |
- Access modes depend on driver and backend capabilities. Choosing RWX in YAML does not turn a single-node block disk into a distributed shared filesystem.
- A Retain reclaim policy keeps released storage for deliberate recovery or cleanup. Delete removes the associated storage through its supported provisioner when reclamation occurs. Know which data may disappear before deleting a claim.
- Storage topology matters: a disk can be restricted to a zone or node. A StorageClass with WaitForFirstConsumer delays binding or provisioning until scheduling information is available, helping avoid incompatible placement.
- Block storage provides devices, file storage provides filesystem access, and object storage exposes objects through an API. A cloud object bucket is not automatically a normal POSIX filesystem volume.
- Persistence is not a backup strategy. Protect against application corruption, accidental deletion and infrastructure loss with appropriate backup, restore testing and storage durability choices.
Choose under exam pressure
| Requirement | Choice and reason |
|---|---|
| Share disposable scratch files between containers in one Pod | A mounted emptyDir |
| Retain application data through Pod replacement | PVC-backed persistent storage with appropriate lifecycle settings |
| Create storage automatically when a claim is submitted | A suitable StorageClass and dynamic provisioner |
| Allow different nodes to write to one supported shared filesystem | RWX-capable storage, not merely an RWX declaration |
| Coordinate storage allocation with workload placement | WaitForFirstConsumer where supported and appropriate |
Traps
- RWO means one node, not necessarily one Pod.
- Deleting a Pod and deleting its PVC are different operations with different data consequences.
- A Pending PVC can indicate missing capacity, an incompatible class or access mode, or delayed binding; it is not always a broken application image.
- A persistent disk can preserve corrupted data just as persistently as correct data.
Active recall
1. A container restarts inside the same Pod. Should its emptyDir workspace disappear solely because of that restart?
No. emptyDir belongs to the Pod's lifetime on the node and can survive individual container restarts. Removing that Pod from the node removes the emptyDir data.
2. An application needs storage but should not choose a specific cloud disk itself. What object should it request?
A PVC describing its requirements, usually with an appropriate StorageClass. Kubernetes and the storage provisioner can bind or provision the backing PV.
3. Does ReadWriteOnce prevent two Pods on the same node from mounting the volume?
Not by itself. RWO restricts read-write mounting to a single node. ReadWriteOncePod expresses the stricter single-Pod requirement with supported CSI volumes.
4. Why might a StorageClass wait until a consuming Pod is scheduled before provisioning a volume?
To consider the workload's topology and placement requirements, such as its zone. Early provisioning could otherwise produce storage that the eligible node cannot use.
5. A PVC is deleted after its backing PV used a Delete reclaim policy. Is it safe to assume the storage remains for later recovery?
No. The backing storage may be deleted as part of reclamation. Check lifecycle settings and maintain a separate tested recovery method before relying on deletion as a reversible action.