What are StorageClasses?
· Category: Kubernetes
Short answer
A StorageClass defines a class of storage in Kubernetes. It specifies the provisioner, such as AWS EBS or NFS, and parameters like performance tier or filesystem type, enabling dynamic provisioning of PersistentVolumes.
How it works
When a PVC references a StorageClass, the provisioner creates a new PV on demand. This eliminates the need for cluster administrators to manually provision volumes. Each StorageClass can represent a different storage tier or backend.
Example
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: fast-ssd
provisioner: kubernetes.io/aws-ebs
parameters:
type: gp3
iopsPerGB: "10"
reclaimPolicy: Retain
allowVolumeExpansion: true
Use in a PVC:
storageClassName: fast-ssd
Why it matters
StorageClasses enable self-service storage for developers and automate backend provisioning. They support tiered storage strategies, allowing applications to request fast SSD or cost-effective HDD storage as needed.
Key differences
- Static provisioning: Admin creates PVs manually.
- Dynamic provisioning: StorageClass creates PVs automatically.
Common issues
- The provisioner must be installed and configured in the cluster.
allowVolumeExpansionrequires CSI driver support.- Retention policies affect whether data is preserved after PVC deletion.