Volumes in Kubernetes
Credit : https://www.debontonline.com/2020/10/part-10-how-to-configure-persistent.html

Volumes in Kubernetes

Containers

Container (can be thought of as a light weight virtual machine) runs logically in a pod.

Pod is a group of one or more containers.

Nodes have worker machines (worker nodes) that host the pods.

Cluster is a group of nodes that run our containerized applications.

In between the three terms Container, Pod and Cluster, we have following relationship :

?????????????Container => Pod => Nodes => Cluster.

Volumes

Every container which runs in a pod can read and write to its own isolated file system. But every time the container is restarted, the filesystem gets destroyed, hence there is lack of persistent data storage. This is where concept of volumes comes into picture.

To brief, volumes in Kubernetes represent a directory with data that is accessible across multiple containers in a Pod.

But again, there is a problem here. The data in the volume gets destroyed when the pod is restarted. The final solution to all these issues is Persistent Volumes. With the help of persistent volumes, the data storage outlives the containers in a Pod and provides long term storage to our Kubernetes cluster.

No alt text provided for this image

How to Create Volumes ?

There are two steps, one step involves specifying the volume for the pod and second involves mounting that volume (volumeMounts) at a specific path (mountpath) inside the container file system.

No alt text provided for this image

Let us try to understand this yaml file from understanding volume perspective. This is a simple pod whose name is nginx-secret-store. Next field is spec.

Spec field is where we describe the object in greater detail. This is where we describe our containers and volumes.

Note that each volume has a name and configuration based on the type of volume. In our case name of volume is secrets-store-online and it is a csi volume type. Next, we look at containers field. It has a name, and volumeMounts.

volumeMounts has the location where the volume will be mounted inside the file system. Note that the name sub-field should have same value inside the “volumes” and “volumeMounts” field.

We can ignore other details for now.

Types of Volumes

Mainly, volumes are categorized into two types

1)?????Those volumes who have lifetime of pod but get destroyed on container restart.

Example: emptyDir, configMap, secret etc.

2)?????Those volumes which persist across containers and restarting of pods.

Example: persistentVolumeClaim, azureDisk etc.

References : Wikipedia, Kubernetes docs etc.

要查看或添加评论,请登录

Shreyansh Sinha的更多文章

  • 5 unique things to know about NaN

    5 unique things to know about NaN

    NaN is not equal to any value, including itself. This means that you cannot test for NaN using the equality operator…

  • Median of Two Sorted Arrays.

    Median of Two Sorted Arrays.

    Median of two sorted arrays. URL : https://leetcode.

社区洞察

其他会员也浏览了