🧡 Kubernetes Storage β€” Masterclass Thread πŸ‘‡πŸ‘‡ From EmptyDir β†’ PV/PVC...

@devops_tech
Rakesh Jain@devops_tech
104 views Dec 18, 2025 ~2 min read
Advertisement
1
🧡 Kubernetes Storage β€” Masterclass Thread πŸ‘‡πŸ‘‡

From EmptyDir β†’ PV/PVC β†’ StorageClasses β†’ CSI β†’ Dynamic Provisioning

#Kubernetes #Storage #DevOps
Media image
2
1️⃣ Storage in k8s β‰  Storage on nodes

Kubernetes does not store data itself.
It only orchestrates how your Pods claim storage from underlying systems (EBS, NFS, Ceph, local disks, etc.)

This abstraction gives portability.
3
2️⃣ Volume: The simplest unit

A volume lives as long as the Pod.
Examples:
emptyDir β†’ temporary workspace
hostPath β†’ use node’s filesystem

Great for build pods, CI pipelines, caches β€” not for real data.
Media image
4
3️⃣ Why Persistent Volumes (PV)?

Pods die β†’ volumes die
Apps need data that outlives pods (DB, MQ, CMS, etc.)
Enter PV + PVC model:

PV β†’ actual storage (NFS, EBS, Ceph, SAN)
PVC β†’ user request for storage
5
4️⃣ PV + PVC = Decoupling

Developers request storage
Ops teams manage backend storage

Example PVC:

If this matches a PV β†’ bound
Media image
6
5️⃣ Access Modes β€” Most misunderstood

Most cloud disks support RWO,
Distributed FS (NFS, CephFS, EFS) support RWX.
Media image
7
6️⃣ StorageClasses β€” default brain of provisioning

Without StorageClass β†’ you must manually create PVs
With StorageClass β†’ volumes get auto-created
β€œKubernetes, give me 20Gi storage”…
β€œDone.”

Example:
Media image
8
7️⃣ Reclaim Policies

Defines what happens to PV after PVC is deleted:
Delete β†’ storage destroyed
Retain β†’ manual cleanup needed
Recycle (deprecated)

Production DBs often use Retain.
9
8️⃣ Dynamic Provisioning β€” The magic

PVC auto-creates storage using StorageClass.

PVC:

Kubernetes:
πŸͺ„ β€œCreating EBS volume…”
πŸͺ„ β€œAttaching to node…”
πŸͺ„ β€œMounting into Pod…”
Media image
10
9️⃣ CSI β€” Container Storage Interface

CSI makes storage plugin based.
No more in-tree drivers.
Supports block, file, snapshots, resizing.

Common CSI drivers:
AWS EBS
Azure Disk/File
GCP PD
Ceph RBD / CephFS
Longhorn
OpenEBS
vSphere CSI
NFS CSI
11
πŸ”Ÿ Volume Snapshots

Database backups got easier.
SnapshotClass + VolumeSnapshot.

Example:
Media image
12
1️⃣1️⃣ Volume Expansion

Resize PVC without deleting Pod (if driver supports it).
Media image
13
1️⃣2️⃣ Local Persistent Volumes

Fastest storage available β†’ local SSDs
But Pod must run on same node β†’ use nodeAffinity.

Great for Kafka, Elastic, Redis.
14
1️⃣3️⃣ Real-World Examples

Example: MySQL with persistent storage
Media image
15
Example: WordPress shared uploads using RWX
Backed by NFS or EFS:

accessModes: ["ReadWriteMany"]

Multiple replicas can write to the same folder.
16
1️⃣4️⃣ Common Mistakes

❌ Using hostPath in production
❌ Using RWO volumes with multiple pods
❌ Using local PVs without nodeAffinity
❌ Forgetting Retain/Delete policy
❌ Storing DB on emptyDir
17
1️⃣5️⃣ Quick Cheatsheet
Media image
18
1️⃣6️⃣ TL;DR

Kubernetes storage is powerful when you follow the chain:

Volume β†’ PersistentVolume β†’ PersistentVolumeClaim β†’ StorageClass β†’ CSI β†’ Snapshots

Master this, and you can run ANY stateful workload on Kubernetes confidently.

#Kubernetes #Storage #DevOps
Media image
Actions
What You Can Do
  • Export as PDF or Markdown
  • Batch Export to Notion
  • Bookmark & Highlight
  • Screenshot Tweet
Create Free Account

Includes 7-day Premium trial

Advertisement