Kubernetes 101 : Dynamic storage provisioning - Storage Classes, Persistent Volumes and Persistent Volume Claim -
Manually provisioning storage (persistent volumes) for the applications running in kubernetes can become complicated for large environments.
We could use kubernetes dynamic provisioning, whereby persistent volumes are dynamically assigned to fill the needs of pods that can ask for storage through a process called persistent volume claim.
Storage classes are at the heart of kubernetes dynamic provisioning.
They offer a way to split storage into different types or classes.
They dynamically provision a storage "PV" that fits the PVCs (request for storage).
Below is a Yaml configuration file of a storage class "storage_1":
The "provisioner" could be "kubernetes.io/aws-ebs" for example.
The "parameters" describe the characteristics of the volumes that the provisioner offers.
The "provisioners" that start with "kubernetes.io" are internal provisioners.
Example : Yaml file of a PVC with a storage class
We can then create the persistent volume clain (PVC) "pvc_1" that uses the storage class "storage_1" using the below command:
We check the creation of the PVC using the below command:
Below is an example of a pod using a persistent volume claim (PVC):
The deployment uses the persistent volume claim (PVC) to request storage for its pods.