What are Storage Classes?
👉 A StorageClass provides a way for administrators to describe the “classes” of storage they offer.
👉 Each StorageClass contains the fields provisioner, parameters, and reclaimPolicy, which are used when a PersistentVolume belonging to the class needs to be dynamically provisioned.
👉 There will always be a default StorageClass in Kubernetes which is used by all PVCs if not specified.
What is a “Default StorageClass” ?
👉 When a PVC does not specify a storageClassName, the default StorageClass is used.
👉 The cluster can only have one default StorageClass. If more than one default StorageClass is accidentally set, the newest default is used when the PVC is dynamically provisioned.
StorageClass Parameters
Now, let’s have a look at some important parameters of the StorageClass Resource:
Provisioner
👉 Each StorageClass has a provisioner that determines what volume plugin is used for provisioning PVs. This field is mandatory.
👉 Examples: kubernetes.io/aws-ebs, kubernetes.io/azure-file etc.
Reclaim Policy
👉 The reclaimPolicy field controls if the PersistentVolume created by the StorageClass should be deleted or retained after it gets released.
👉 The reclaimPolicy can be either `Delete` or `Retain`.
👉 The default value is `Delete` if no reclaimPolicy is specified.
Allow Volume Expansion
👉 PersistentVolumes can be configured to be expandable.
👉 This feature when set to true, allows the users to resize the volume by editing the corresponding PVC object.
👉 You can only use the volume expansion feature to grow a Volume, not to shrink it.
Mount Options
👉 PVs created by Storage classes will have the mount options specified in the `mountOptions` field of the class.
👉 If a mount option is invalid or is not supported by the Volume plugin, the PV mount fails.
Volume Binding Mode
👉 The `volumeBindingMode` field controls when volume binding and dynamic provisioning should occur.
👉 There can be two possible values for volumeBindingMode:
1️⃣ Immediate Mode
☑ The Immediate mode indicates that volume binding and dynamic provisioning occurs once the PersistentVolumeClaim is created.
2️⃣ WaitForFirstConsumer Mode
☑ mode which will delay the binding and provisioning of a PersistentVolume until a Pod using the PersistentVolumeClaim is created.