3 min to read
Understanding Kubernetes Storage - PV, PVC, StorageClass, and CSI-Driver
A comprehensive guide to Kubernetes storage components and their interactions

Overview
This guide explores Kubernetes storage components, including Persistent Volumes (PV), Persistent Volume Claims (PVC), StorageClass, and Container Storage Interface (CSI) drivers.
Kubernetes Volumes
Persistent Volumes (PV)
- Cluster-level storage resources provisioned by administrators or dynamically via StorageClass
- Independent lifecycle from pods
- Abstracts storage provisioning details
- Supports various access modes:
- ReadWriteOnce: Single node read-write mounting
- ReadOnlyMany: Multiple node read-only mounting
- ReadWriteMany: Multiple node read-write mounting
Persistent Volume Claims (PVC)
- User storage requests
- Automatically binds to suitable PVs
- Referenced by name in pods
- Specifies size and access mode requirements
🔄 PV Lifecycle Management
persistentVolumeReclaimPolicy
- Retain: Preserves volume and data after release (default)
- Delete: Removes volume when PVC is deleted
- Recycle: Legacy policy, not recommended for dynamic provisioning
Lifecycle Phases
- Provisioning: Static or dynamic via StorageClass
- Binding: PVC creation and matching to available PV
- Using: Pod mounts and uses the volume
- Releasing: PVC deletion
- Reclaiming: Based on reclaim policy
StorageClass & CSI Implementation
The storage class provides a way to describe the “classes” of storage provided by the administrator.
It provides a standardized way to abstract the details of the underlying storage platform and dynamically provision PV.
Container storage interface (CSI) is a standard for exposing various block and file storage systems to containerized workloads in container orchestration systems (COSs), such as Kubernetes.
CSI’s goal is to provide a consistent and standardized API for storage solutions, making it easy to integrate and use storage products in a cloud native ecosystem.
StorageClass Example
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: standard
provisioner: kubernetes.io/aws-ebs
parameters:
type: gp2
reclaimPolicy: Delete
allowVolumeExpansion: true
PV Example
apiVersion: v1
kind: PersistentVolume
metadata:
name: example-pv
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: standard
awsElasticBlockStore:
volumeID: vol-xxxxx
fsType: ext4
PVC Example
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: example-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: standard
Pod Using PVC
apiVersion: v1
kind: Pod
metadata:
name: example-pod
spec:
containers:
- name: app
image: nginx
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: storage
volumes:
- name: storage
persistentVolumeClaim:
claimName: example-pvc
Container Storage Interface (CSI)
- Block Storage: For performance-critical applications
- File Storage: For shared storage systems
- Object Storage: For unstructured data
Available Pod Volume Types
- hostPath: Mounts host node filesystem
- emptyDir: Temporary directory shared with pod lifecycle
- CSI Volumes: Provider-specific implementations
Comments