Table of contents
Open Table of contents
How does Kubernetes manage storage?
Pods are temporary. If a pod restarts or is rescheduled, anything written inside the container is lost.
So storage cannot live inside the pod.
Kubernetes solves this by separating storage from pods.
Main components
There are 3 main components that Kubernetes use for storage:
- PV (Persistent Volume)
- PVC (Persistent Volume Claim)
- SC (Storage Class)
Persistent Volume
A volume is something we mount into a pod. It can be shared by containers in the same pod.
But the volume still lives only as long as the pod exists, so it’s not useful for permanent data.
For persistence, Kubernetes uses Persistent Volumes.
A Persistent Volume represents real storage in the cluster. It could be cloud disk, NFS, or local disk.
It exists even if no pod is using it.
Persistent Volume Claim
Applications do not use Persistent Volumes directly.
They create a Persistent Volume Claim instead. A PVC is just a request saying how much storage is needed and how it will be accessed.
Kubernetes finds a matching PV and binds it.
Storage Class
StorageClass defines how storage is created.
It hides cloud specific details and allows volumes to be created automatically when a PVC is created.