Key Concepts
StorageClass
A cluster-scoped template that defines how storage should be provisioned.
Provisioner
The volume plugin that creates PVs (e.g., CSI drivers, cloud providers).
Binding Mode
When to provision storage: immediately or when a pod needs it.
Default Class
The StorageClass used when PVCs don’t specify one.
StorageClasses are cluster-scoped resources. They are available to all namespaces and define how storage is provisioned across the entire cluster.
Required Permissions
| Action | Permission |
|---|---|
| View StorageClasses | iam:project:infrastructure:kubernetes:read |
| Create StorageClass | iam:project:infrastructure:kubernetes:write |
| Edit StorageClass | iam:project:infrastructure:kubernetes:write |
| Delete StorageClass | iam:project:infrastructure:kubernetes:delete |
Key Fields
| Field | Description |
|---|---|
| provisioner | The volume plugin that creates PVs (required) |
| reclaimPolicy | What happens to PV when PVC is deleted (Delete or Retain) |
| volumeBindingMode | When to bind PV to PVC (Immediate or WaitForFirstConsumer) |
| allowVolumeExpansion | Whether PVCs can be resized after creation |
| parameters | Provisioner-specific configuration options |
| mountOptions | Options passed to the mount command |
Volume Binding Modes
| Mode | Description |
|---|---|
| Immediate | PV is provisioned as soon as PVC is created (default) |
| WaitForFirstConsumer | PV is provisioned when a pod using the PVC is scheduled |
How to View StorageClasses
How to View StorageClass Details
Review Details
View StorageClass information including:
- Overview: Name, provisioner, reclaim policy, binding mode, age
- Features: Volume expansion, default status
- Parameters: Provisioner-specific configuration
- Mount Options: Mount command options
- Allowed Topologies: Zone/region constraints
- Labels & Annotations: Metadata
How to Create a StorageClass
Write YAML
Enter the StorageClass manifest in YAML format. Key fields:
provisioner- Volume plugin identifier (required)reclaimPolicy- Delete or RetainvolumeBindingMode- Immediate or WaitForFirstConsumerallowVolumeExpansion- true/falseparameters- Provisioner-specific options
How to Edit a StorageClass
Modify Spec
Edit the StorageClass specification. Note that most fields are immutable after creation.
How to Delete a StorageClass
Default StorageClass
One StorageClass can be marked as the cluster default. PVCs that don’t specify astorageClassName will use the default class.
Setting the default:
| Annotation | Description |
|---|---|
storageclass.kubernetes.io/is-default-class | Set to "true" for default (recommended) |
storageclass.beta.kubernetes.io/is-default-class | Legacy annotation, also supported |
Only one StorageClass should be marked as default. If multiple are marked, behavior is undefined and may vary by Kubernetes version.
Example StorageClasses
AWS EBS (CSI)
Google Cloud Persistent Disk
Azure Disk
Local Storage
NFS (External Provisioner)
Common Provisioners
| Provisioner | Description |
|---|---|
ebs.csi.aws.com | AWS EBS CSI driver |
pd.csi.storage.gke.io | Google Cloud Persistent Disk CSI |
disk.csi.azure.com | Azure Disk CSI driver |
file.csi.azure.com | Azure File CSI driver |
csi.vsphere.vmware.com | VMware vSphere CSI |
rook-ceph.rbd.csi.ceph.com | Rook Ceph block storage |
kubernetes.io/no-provisioner | No dynamic provisioning (local storage) |
Troubleshooting
PVC stuck in Pending with no provisioner
PVC stuck in Pending with no provisioner
- Verify the StorageClass exists
- Check provisioner pods are running
- Ensure CSI driver is properly installed
- Check for errors in provisioner logs
Volume provisioned in wrong zone
Volume provisioned in wrong zone
- Use
volumeBindingMode: WaitForFirstConsumer - Configure
allowedTopologiesif needed - Verify pod has appropriate node selectors
Volume expansion not working
Volume expansion not working
- Verify
allowVolumeExpansion: truein StorageClass - Check if the provisioner supports expansion
- Pod restart may be required for filesystem expansion
- Check PVC conditions for resize status
Cannot create PVC with StorageClass
Cannot create PVC with StorageClass
- Verify StorageClass exists:
kubectl get sc - Check PVC
storageClassNamematches exactly - Verify provisioner has necessary permissions
- Check provisioner logs for errors
Default StorageClass not being used
Default StorageClass not being used
- Verify annotation is exactly
storageclass.kubernetes.io/is-default-class: "true" - Ensure only one StorageClass is marked as default
- Check PVC doesn’t explicitly set
storageClassName: ""
Parameters not taking effect
Parameters not taking effect
- Parameters are passed directly to the provisioner
- Check provisioner documentation for valid parameters
- Verify parameter values are strings (quoted in YAML)
- Invalid parameters may be silently ignored
FAQ
What is dynamic provisioning?
What is dynamic provisioning?
Dynamic provisioning automatically creates PVs when PVCs are created. The StorageClass specifies the provisioner and parameters used to create the storage. No manual PV creation is needed.
When should I use WaitForFirstConsumer?
When should I use WaitForFirstConsumer?
Use WaitForFirstConsumer when:
- Using multi-zone clusters
- Storage must be in the same zone as the pod
- Using local persistent volumes
- Topology-aware provisioning is needed
Can I change a StorageClass after creation?
Can I change a StorageClass after creation?
Most fields are immutable (provisioner, parameters, reclaimPolicy, volumeBindingMode). You can only modify labels, annotations, and allowVolumeExpansion. To change other fields, delete and recreate the StorageClass.
What happens to existing PVCs if I delete a StorageClass?
What happens to existing PVCs if I delete a StorageClass?
Existing PVCs and PVs are not affected. They retain their original settings. Only new PVCs cannot use the deleted StorageClass.
Should I have multiple StorageClasses?
Should I have multiple StorageClasses?
Yes, typically. Create different StorageClasses for:
- Different performance tiers (SSD vs HDD)
- Different reclaim policies (Delete vs Retain)
- Different use cases (databases vs logs)
- Different availability zones or regions
What is the difference between Delete and Retain reclaim policies?
What is the difference between Delete and Retain reclaim policies?
Delete: When PVC is deleted, PV and underlying storage are automatically deleted. Good for ephemeral data.Retain: PV is kept when PVC is deleted, allowing manual data recovery. The PV enters “Released” state.
How do mount options work?
How do mount options work?
Mount options are passed to the
mount command when attaching volumes. Common options include ro (read-only), noatime, nodiratime. Not all provisioners support mount options.What are allowed topologies?
What are allowed topologies?
Allowed topologies restrict where volumes can be provisioned based on node labels (typically zones/regions). This ensures volumes are only created in specific locations, useful for compliance or performance requirements.