πΎ StorageClasses Create Volumes Automatically
Manual volume creation is tedious. StorageClasses provision volumes dynamically. Specify storage type, size, performance.
π StorageClass Examples
apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: fast-ssd provisioner: kubernetes.io/aws-ebs parameters: type: gp3 encrypted: "true" iopsPerGB: "50" allowVolumeExpansion: true --- apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: standard provisioner: kubernetes.io/aws-ebs parameters: type: gp2 encrypted: "true" --- apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: slow-hdd provisioner: kubernetes.io/aws-ebs parameters: type: st1
π― Using StorageClass
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: fast-storage
spec:
accessModes:
- ReadWriteOnce
storageClassName: fast-ssd
resources:
requests:
storage: 10Gi
# When PVC is created, PV is automatically provisioned
# kubectl get pv β shows new volume
# Default StorageClass
kubectl patch storageclass standard -p '{"metadata": {"annotations":{"storageclass.kubernetes.io /is -default -class":"true"}}}'
< h4 style='color: #856404; margin: 0 0 20px 0; font-size: 1.7em; font-weight: 700;'>π‘ Cloud Providers
-
< li > AWS: kubernetes.io/aws-ebs (EBS)
- Azure: kubernetes.io/azure-disk
- GCP: kubernetes.io/gce-pd
- Local: kubernetes.io/no-provisioner (static)
- NFS: nfs(custom provisioner)
< p style='font-size: 1.4em; line-height: 1.7; margin: 0; color: #006064; font-style: italic; font-weight: 500;'>“StorageClass created EBS volumes automatically.No manual volume provisioning.Dynamic storage is essential for stateful apps.”
