A Volume is mounted inside a Pod and survives container restarts.
Container ↓ /app/data → Volume
Volumes are defined at the Pod level, not container level.
Common Ways to Use Filesystem in Kubernetes
- emptyDir (Temporary Shared Storage) What it is: Temporary storage Created when Pod starts Deleted when Pod is removed
Use case: Sharing files between containers Caching Scratch space
- hostPath (Node Filesystem Access) Mounts a directory from the node’s filesystem.
Problems: Tied to one node Not portable Security risks
Use mostly for: Development DaemonSets Log collectors
- PersistentVolume (PV) + PersistentVolumeClaim (PVC)
Pod → PVC → PV → Storage Backend
Step 1: Create PVC Step 2: Mount in Pod
Access Modes
| Mode | Meaning |
|---|---|
| ReadWriteOnce | Mounted by one node |
| ReadOnlyMany | Many nodes, read only |
| ReadWriteMany | Many nodes, read/write |
