XenonStack Recommends

Kubernetes

Storage Class in Kubernetes and its Management

Navdeep Singh Gill | 02 June 2023

Storage Class in Kubernetes and its Management

Overview of Storage Class in Kubernetes

To understand the concept of storage class in kubernetes, first, we need to understand the volume concept in Kubernetes. In simple terms, kubernetes volume is a directory where our data is stored; containers inside pods in kubernetes use this volume to persist their data; Kubernetes supports many types of volumes like persistent volume, Ephemeral volume, and Projected Volume.

Here the Storage class concept will be around persistent volume type, which we will discuss in this document. In persistence volume, we have two things to discuss before moving towards storage class, i.e., two APIs provided by Kubernetes PersistentVolumeClaim and PersistenceVolume; the reason for providing two APIs instead of directly provisioning storage to the pod is to hide some information like from where storage has been provided and where it is used.

An open-source system, developed by Google, an orchestration engine for managing containerized applications over a cluster of machines. Taken From Article, Kubernetes Deployment Tools and Best Practices

PersistentVolume is either created by the administrator or dynamically provisioned with the help of the Storage class; this resource is available at the cluster level, just like the node and any other resources available at the cluster level.

PersistentVolumeClaim is the resource from which we request the storage PersistenVolumeClaim uses PersistencVolume just like pod uses node resources. PersistentVolumeClaim allows users to utilize abstract storage provided by the administrator in the form of PersistentVolume.

What is Storage Class in Kubernetes?

Storage class is the Kubernetes resources from which we achieve dynamic, persistent volume provisioning. The storage class concept in kubernetes provides a way for the user(administrator) to provide the type of storage they want to offer. To do all this, the administrator needs to create the class.

Below is the way we can create the storage class in Kubernetes.

apiVersion: storage.k8s.io/v1

kind: StorageClass

Metadata:

name: standard

provisioner: kubernetes.io/aws-ebs

Parameters:

type: gp2

reclaimPolicy: Retain

allowVolumeExpansion: true

Mount options:

- debug

volumeBindingMode: Immediate

Provisioner, parameters, and reclaimPolicy these three fields must be in every storage class the administrator makes.

Here Provisioner section, we assign different volume plugins; our Pv's are created using this plugin. In the above example, we have used aws-ebs

What is the importance of Storage Class?

In Kubernetes, storage classes are an essential concept that provides a way to define different types of storage that can be used by persistent volume claims (PVCs) in a cluster.

Here are some of the critical reasons why storage classes are essential in Kubernetes:

  • Flexibility: Storage classes allow to definition of multiple types of storage, such as network-attached storage (NAS), block storage, and object storage, and make them available to the applications. This gives flexibility to choose the type of storage that best fits the needs of an application.
  • Automation: Kubernetes storage classes can be automated, which means that when a user creates a new PVC, Kubernetes can dynamically provision a new volume using the appropriate storage class. This can save time and reduce errors, as the user cannot manually create and manage the volumes.
  • Performance: Storage classes can also define performance characteristics such as disk speed, IOPS, and latency. This helps ensure that the storage resources used by the application meet the necessary performance requirements.
  • Storage Management: Storage classes can also be used to manage the lifecycle of storage resources, such as by defining retention policies and backup schedules. This makes it easier to manage and monitor storage resources in the cluster.
Serverless Framework is serverless computing to build and run applications and services without thinking about the servers. Taken From Article, Kubeless - Kubernetes Native Serverless Framework

What are the types of Storage Class?

There are several different types of storage classes in Kubernetes, each with its own set of features and use cases. Let's explore each of these types in more detail.

Standard Storage Class

The standard storage class is the default storage class in Kubernetes. It is used when no other storage class is specified. This storage class uses the default settings of the underlying infrastructure, which may be a cloud provider, a local disk, or a network-attached storage device. The standard storage class is ideal for applications that do not require specific performance or availability requirements.

Managed Storage Class

The managed storage class provides managed storage resources, such as Amazon Elastic Block Store (EBS) or Google Cloud Persistent Disks. The cloud provider manages These storage resources and offers high availability and durability. Managed storage classes are ideal for applications that require reliable storage with high availability and durability.

What are the various types of Managed Storage Classes in Kubernetes?

Let's see some managed storage classes in kubernetes:

AWS EBS Storage Class

The AWS EBS storage class is used to provision and manage storage volumes in the AWS Elastic Block Store. This storage class is commonly used by developers deploying their applications on the Amazon Web Services (AWS) cloud platform.

Azure Disk Storage Class

The Azure Disk storage class provides and manages storage volumes in Microsoft Azure Disk Storage. This storage class is commonly used by developers deploying their applications on the Microsoft Azure cloud platform.

GCE Persistent Disk Storage Class

The GCE Persistent Disk storage class is used to provision and manage storage volumes in the Google Compute Engine Persistent Disk. This storage class is commonly used by developers deploying their applications on the Google Cloud Platform (GCP).

Network File System (NFS) Storage Class

The Network File System (NFS) storage class provides shared storage accessible from multiple nodes in the cluster. This storage class is ideal for shared storage applications like databases or file servers. However, ensuring that the NFS server is highly available and reliable is essential to prevent data loss.

Managing Storage Classes in Kubernetes

Kubernetes provides various tools that can be used to manage storage classes in a Kubernetes cluster. Let's take a look at some of the standard management tasks that need to be performed on storage classes in Kubernetes.

Creating a Storage Class

To create a storage class in Kubernetes, one must define the storage class specifications in a YAML file and then use the kubectl to apply the command to create the class.

For example, here is a sample YAML file that defines an AWS EBS storage class:

apiVersion: storage.k8s.io/v1

kind: StorageClass

Metadata:

name: aws-ebs

provisioner: kubernetes.io/aws-ebs

Parameters:

type: gp2

Modifying a Storage Class

To modify a storage class in Kubernetes, you need to update the specifications in the YAML file and then use the kubectl apply the command to apply the changes.

For example, if someone wants to change an AWS EBS storage class type from gp2 to io1, one can update the parameters section in the YAML file and then apply the changes using the kubectl apply command.

Deleting a Storage Class

To delete a storage class in Kubernetes, one needs to use the kubectl delete command and specify the name of the storage class one wants to delete.

For example, if suppose one wants to delete an NFS storage class named nfs-storage, then one can use the following command:

kubectl delete storage-class nfs-storage

Containers are helpful to move an application for deployment in different environments quickly. Taken From Article, Container Design Patterns for Kubernetes

Conclusion

In conclusion, storage classes in Kubernetes provide a powerful and flexible way to manage storage for containerized applications. By defining different storage classes with specific features and parameters, developers can quickly provision and manage storage resources that meet the needs of their applications. Whether there is a need for high availability and durability, low latency and high performance, or shared storage for databases and file servers, Kubernetes has a storage class that can meet needs.

As Kubernetes continues to evolve and improve, we expect to see more powerful storage options and features added to the platform. In the meantime, developers can take advantage of the existing storage classes to build