Open In App

Kubernetes Volume Provisioning: Dynamic VS Static

Are you facing issues in allocating resources in the Kubernetes Environment? If yes, look no further guides. We are here to help you with this insightful article which covers a detailed explanation of the Kubernetes Volume Provisioning. If you reach to end of this guide, all your doubts about the Kubernetes Volume Provisioning will be resolved.

Deploying applications in the form of containers is one of the most widely acceptable approaches in today’s world. But, allocating storage to those containers is equally important. This helps us to ensure the durability and high availability of the containerized workloads. Hence, it becomes important to learn various Volume Provisioning Strategies to make our Kubernetes Environment scalable.



In this article, we will learn about Volume Provisioning and its types namely, static and dynamic. So, let us start without any delay.

Overview Of Kubernetes

Kubernetes, also known as K8 is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. In the Kubernetes, the containers are the entities that store the applications along with their dependencies. These containers are grouped into logical units called pods. These pods are present inside the Node, which may be physical or virtual machines. Each Node runs a Kubernetes agent called Kubelet that manages the containers and communicates with the Kubernetes control plane. However, when it comes to storing the data, the pods require some storage volumes in which the data persist even after the lifecycle of the container.

What Is Volume Provisioning?

Whenever we create the files or store the data in Kubernetes, all the data storage goes away once the Container Stops running. To prevent this, we have to allocate some volumes to the Kubernetes Containers so that the data remains persistent even if the container stops. This technique is known as Volume Provisioning in the Kubernetes.

However, before provisioning the resources, there should be a Storage Class in the Kubernetes Cluster. This is due to the fact that the StorageClass Objects store the provisioner, parameters, and reclaimPolicy for the data. Let us first see the types of Volumes that can be provisioned.

What Is Static Volume Provisioning?

Static volume provisioning in Kubernetes refers to the manual allocation and configuration of storage volumes before they are needed by pods. Static provisioning requires administrators to pre-allocate and manage storage resources in advance so that the data remains persistent after the containers stop running. This is implemented using the Persistent Volumes (storage resources in Kubernetes) and PersistentVolumes Claims (PVC), which are the requests made by pods for storage. This process is illustrated as shown below.

Implementation Of Static Volume Provisioning

apiVersion: v1
kind: PersistentVolume
metadata:
name: my-pv
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
hostPath:
path: /data/my-pv
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi

OUTPUT

What Is Dynamic Volume Provisioning?

There might be a case when the PersistentVolumeClaims (request for storage) does not match with the Persistent Volume created by the administrator. In this case, the cluster dynamically provisions the volume for the PVC. This is implemented using the concept of StorageClass.

First, the administrator defines the StorageClass that contains the fields provisioner, parameters, and reclaimPolicy. Then, the PVC requests the StorageClass to dynamically provision the storage volumes to the pod. You can understand the entire workflow through the below points.

Implementation Of Dynamic Volume Provisioning

 kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: fast
provisioner: kubernetes.io/aws-ebs
parameters:
type: gp2
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-dynamic-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi

OUTPUT

Static Vs Dynamic Volume Provisioning: Key Differences

The following are the key differences between static and dynamic volume provisioning:

Static Provisioning

Dynamic Provisioning

In this technique, the Administrators manually allocate and configure storage volumes.

Here, the Storage volumes are automatically provisioned based on demand.

It requires manual intervention and pre-allocation of resources.

It automates the provisioning process and reduces the manual effort.

If resources are allocated more or less the than the requirement, this may lead to the underutilization of resources.

This technique optimizes resource usage by provisioning volumes on demand.

It is more complex to manage and maintain at scale.

This simplifies storage management and improves cluster efficiency.

Ideal for environments with predictable storage requirements.

It is well-suited for dynamic workloads and cloud-native environments.

Conclusion

To conclude, Kubernetes is popular and efficient for containerization of the applications. However, we may face challenges when the container stops running as the data storage goes away. Kubernetes provides Storage Provisioning to overcome this challenge. It involves the allocation of the storage volumes to the pods.

We can provision the storage volumes both statically through the manual configuration or dynamically using the StorageClass Objects. After we have gained a clear understanding of the Storage Provisioning the Kubernetes, we can easily optimize our Kubernetes Workflow.

Kubernetes Volume Provisioning – FAQ’s

Which Storage Providers Are Supported For Dynamic Volume Provisioning In Kubernetes?

Kubernetes supports various storage providers for dynamic volume provisioning, including cloud storage services like AWS EBS, GCP PD, and Azure Disk, as well as network-attached storage (NAS) and local storage options.

What Is The Difference Between Volume Mounting And Volume Binding In Kubernetes?

Volume mounting refers to the process of attaching a storage volume to a specific directory within the filesystem of a pod. But the Volume binding is the process of associating a PersistentVolume (PV) with a PersistentVolumeClaim (PVC). First, the Volume binding between the PV and PVC is done. Then, the Kubernetes mounts the PV into the designated directory within the pod so that they can access and utilize the storage volume.

What Is The Difference Between PV And PVC In Kubernetes?

In the Kubernetes Storage Provisioning, the PersistentVolumes represent actual storage resources available in the cluster. On the other hand, PersistentVolumeClaims serve as requests made by pods for access to those storage resources. Thus PVC specifies the storage requirements, such as size and access mode and PVs represent the available storage pool.

What Are Stateful And Stateless Workloads In Kubernetes?

Stateful workloads are applications that require persistent data storage and maintain some form of state or data between sessions or instances. For example, the databases, file systems, and messaging queues require that our data should be persistent. However, the applications that do not maintain any state or data between sessions or instances are stateless workloads. The stateless applications may include web servers, microservices, and API gateways.


Article Tags :