In Kubernetes, Dynamic volume provisioning is a mechanism which allows storage volumes to be created on-demand. Kubernetes Cluster uses concept of Storage class to achieve the same. Storage class another type of object in Kubernetes which allows you to abstract the details of underlying storage in a simple fashion. Kubernetes uses a system of persistent volume claim (PVC) and persistent volume (PV) to simplify storage operations with help of Storage Class (SC).
A cluster administrator can define as many
StorageClass objects as needed, each specifying a volume plugin ( provisioner) that provisions a volume and the set of parameters to pass to that provisioner when provisioning.
kind: Managed#You can make any StorageClass as default, by adding the #storageclass.kubernetes.io/is-default-class annotation to it.
To access the Storage you must create the object PVC (PersistentVolumeClaim). PVC is the request to provision persistent storage with a specific type and configuration. PVC uses Storage class to create specific request to provisioner for storage creation. That’s it once PVC is in the system, rest of the things will be taken care by k8s cluster. ex: storage creation in cloud, PV creation and management etc.
This is dynamic volume provisioning !
Creating a PVC in a cluster automatically triggers the storage plug-in for the requested type of storage to provision storage with the given specification.
You StorageClass will have storage account definition to use otherwise default storage account will be used to create storage.
Storage plug-in automatically creates a persistent volume (PV, virtual storage device) in the cluster, which maps to storage in Cloud. Status of the PVC and the PV changes to
Now PVC Mounts that storage in POD if it is part of POD definition.
SC plays an important role in case of Dynamic provisioning. Each StorageClass has a provisioner that determines what volume plugin is used for provisioning PVs. Above mentioned SC defines Azure File Storage.
reclaimPolicy defines what will happen to storage once you delete the PVC.
Retain are two values which can be used here. As the name
volumeBindingMode field controls when volume binding and dynamic provisioning should occur. Two values —
Immediate mode indicates that volume binding and dynamic provisioning occurs once the PersistentVolumeClaim is created.
WaitForFirstConsumer mode will delay the binding and provisioning of a PersistentVolume until a Pod using the PersistentVolumeClaim is created. This is useful when storage backends that are topology-constrained and not globally accessible. This Mode suits when you have a multi-zone cluster in place and storage is bound to Zones.
We will talk about more on
WaitForFirstConsumer mode in next post.
That’s all for this post. Thanks.
Keep Learning !