PART 1: CORE THEORY
1. The Kubernetes Storage Model
Kubernetes storage is built on three core objects that separate what the application needs from how the infrastructure provides it.
The Three Core Objects
| Object | Purpose | Created By |
| PersistentVolume (PV) | The actual storage resource | Admin (static) or CSI driver (dynamic) |
| PersistentVolumeClaim (PVC) | The application's request for storage | Application developer |
| StorageClass | The policy template for provisioning | Cluster admin |
The Mental Model
Applications request storage through a PersistentVolumeClaim. The cluster satisfies that request through a PersistentVolume. A CSI driver is the integration layer that makes the underlying storage system usable from Kubernetes.
Why This Separation Matters
| Without Abstraction | With Abstraction |
| App knows about EBS, GCP PD, NFS | App knows only about PVC |
| Changing storage = changing app | Changing storage = changing StorageClass |
| No portability | Portable across clusters |
| No access control | RBAC for storage |
The Five Questions
When choosing storage, answer these five questions:
- Data path type: Block, file, or object-adjacent?
- Concurrent access: How many Pods need to read/write?
- Performance: What latency and throughput profile?
- Failure domain: Node, zone, or region?
- Operational controls: Snapshots, expansion, backup, retention?
2. CSI (Container Storage Interface)
CSI is the standard plugin model that Kubernetes uses to provision, attach, mount, resize, snapshot, and clone volumes.
What CSI Replaced
Before CSI, storage drivers were in-tree (compiled into Kubernetes). This meant:
- Adding new storage required a Kubernetes release
- Updating drivers required a cluster upgrade
- Vendors couldn't iterate quickly
CSI moves drivers out-of-tree. Vendors maintain their own drivers, and Kubernetes just talks to them via a standard gRPC interface.
The CSI Architecture
text
┌─────────────────────────────────────────────────────────────┐
│ CSI ARCHITECTURE │
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Kubernetes Control Plane │ │
│ │ ┌─────────────┐ ┌─────────────┐ │ │
│ │ │ CSI │ │ CSI │ │ │
│ │ │ Controller │ │ Provisioner │ │ │
│ │ │ (StatefulSet│ │ (external) │ │ │
│ │ └──────┬──────┘ └──────┬──────┘ │ │
│ └─────────┼────────────────┼──────────────────────────┘ │
│ │ │ │
│ ▼ ▼ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ CSI Driver (Deployed by vendor) │ │
│ │ ┌─────────────────────────────────────────────┐ │ │
│ │ │ Controller Plugin (StatefulSet) │ │ │
│ │ │ • CreateVolume, DeleteVolume │ │ │
│ │ │ • ControllerPublishVolume │ │ │
│ │ │ • CreateSnapshot, DeleteSnapshot │ │ │
│ │ └────────────────────┬────────────────────────┘ │ │
│ │ │ │ │
│ │ ┌────────────────────▼────────────────────────┐ │ │
│ │ │ Node Plugin (DaemonSet) │ │ │
│ │ │ • NodeStageVolume, NodePublishVolume │ │ │
│ │ │ • NodeUnpublishVolume │ │ │
│ │ └──────────────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
Major CSI Drivers
| Driver | Cloud | Storage Type |
| ebs.csi.aws.com | AWS | Block (EBS) |
| efs.csi.aws.com | AWS | File (EFS) |
| pd.csi.storage.gke.io | GCP | Block (Persistent Disk) |
| filestore.csi.storage.gke.io | GCP | File (Filestore) |
| disk.csi.azure.com | Azure | Block (Azure Disk) |
| file.csi.azure.com | Azure | File (Azure Files) |
| cephfs.csi.ceph.com | On-prem | File (CephFS) |
| rbd.csi.ceph.com | On-prem | Block (Ceph RBD) |
| driver.longhorn.io | On-prem | Block (Longhorn) |
2026 Recommendations:
- AWS → EBS CSI (gp3)
- GCP → PD CSI (SSD)
- Azure → Disk CSI (Premium)
- On-Prem (<50 nodes) → Longhorn
- On-Prem (50+ nodes) → Rook-Ceph
- RWX needed → Cloud Files or CephFS
3. PersistentVolumes (PV)
A PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by an administrator or dynamically by a StorageClass.
PV Lifecycle
| Phase | Meaning |
| Available | Not yet bound to a PVC |
| Bound | Bound to a PVC |
| Released | PVC deleted, PV not yet reclaimed |
| Failed | Automatic reclamation failed |
Static PV Example
yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: my-pv
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: manual
hostPath:
path: /mnt/data
Reclaim Policies
| Policy | Behavior |
| Retain | Data preserved after PVC deletion; manual cleanup required |
| Delete | PV and underlying storage deleted |
| Recycle | Deprecated; basic scrub |
Volume Modes
| Mode | Behavior |
| Filesystem | Mounted as a directory (default) |
| Block | Raw block device |
4. PersistentVolumeClaims (PVC)
A PersistentVolumeClaim (PVC) is the application's request for storage. It specifies capacity, access mode, and optionally a StorageClass.
PVC Example
yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-claim
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: fast-ssd
PVC Binding
The control plane watches for new PVCs and finds a matching PV (by capacity, access mode, StorageClass). If a PV is found, they are bound. If no PV matches but a StorageClass is specified, a new PV is dynamically provisioned.
PVC Status
| Status | Meaning |
| Pending | Not yet bound |
| Bound | Bound to a PV |
| Lost | PV no longer available |
Using a PVC in a Pod
yaml
spec:
containers:
- name: app
image: myapp:1.0
volumeMounts:
- name: data
mountPath: /data
volumes:
- name: data
persistentVolumeClaim:
claimName: my-claim
PVC Retention
By default, PVCs are not deleted when a StatefulSet is deleted. This preserves data. To delete PVCs, you must do so manually or use a tool like Velero.
5. StorageClasses
A StorageClass is a policy template that defines how volumes are provisioned.
StorageClass Example
yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: fast-ssd
provisioner: ebs.csi.aws.com
parameters:
type: gp3
iops: "3000"
throughput: "125"
encrypted: "true"
reclaimPolicy: Delete
allowVolumeExpansion: true
volumeBindingMode: WaitForFirstConsumer
Key Parameters
| Parameter | Purpose |
| provisioner | CSI driver to use |
| parameters | Driver-specific settings (type, IOPS, encryption) |
| reclaimPolicy | Delete or Retain |
| allowVolumeExpansion | Enable online resize |
| volumeBindingMode | Immediate or WaitForFirstConsumer |
Volume Binding Modes
| Mode | Behavior |
| Immediate | Provision before Pod scheduling |
| WaitForFirstConsumer | Provision after Pod scheduling (topology-aware) |
Production recommendation: Use WaitForFirstConsumer for all storage classes. This ensures volumes are provisioned in the same zone as the Pod.
Default StorageClass
yaml
metadata:
annotations:
storageclass.kubernetes.io/is-default-class: "true"
The default StorageClass is used when a PVC doesn't specify storageClassName.
2026 StorageClass Best Practices
| Practice | Why |
| Use WaitForFirstConsumer | Topology-aware provisioning |
| Enable allowVolumeExpansion | Online resize |
| Set reclaimPolicy: Retain | Data safety for critical workloads |
| Multiple classes | Different performance tiers |
| Mount options | Performance tuning (rsize, wsize, nconnect) |
6. Access Modes
Access modes define how many nodes can mount a volume and whether they can write.
The Four Access Modes
| Mode | Abbreviation | Meaning |
| ReadWriteOnce | RWO | Mounted read-write by a single node |
| ReadOnlyMany | ROX | Mounted read-only by many nodes |
| ReadWriteMany | RWX | Mounted read-write by many nodes |
| ReadWriteOncePod | RWOP | Mounted read-write by a single Pod |
Access Mode by Storage Type
| Storage Type | RWO | ROX | RWX | RWOP |
| Block (EBS, PD, Azure Disk) | ✅ | ❌ | ❌ | ✅ |
| File (EFS, Filestore, Azure Files) | ✅ | ✅ | ✅ | ✅ |
| Ceph RBD | ✅ | ✅ | ❌ | ✅ |
| CephFS | ✅ | ✅ | ✅ | ✅ |
| Longhorn | ✅ | ❌ | ✅ | ✅ |
| Local PV | ✅ | ❌ | ❌ | ✅ |
When to Use Each
| Use Case | Access Mode |
| Database (PostgreSQL, MySQL) | RWO |
| Message queue (Kafka) | RWO |
| Shared CMS media | RWX |
| Read-only config | ROX |
| Single Pod with strict isolation | RWOP |
RWOP (ReadWriteOncePod)
Introduced in Kubernetes 1.22, GA in 1.29. RWOP ensures only one Pod can mount the volume read-write. This is stricter than RWO (which allows multiple Pods on the same node).
yaml
spec:
accessModes:
- ReadWriteOncePod
1:1 copy of the class Google Doc, code in code blocks.