What is a Kubernetes Persistent Volume?

Last Updated:
February 19, 2023
Author:
Kay Nicole

What is a Kubernetes Persistent Volume

A Kubernetes persistent volume is a piece of cluster storage that persists data to be used by containers throughout their lifecycle. With an ongoing book, data would be recovered as Pods is replaced or resized.

Kubernetes exposes physical storage implementations to PODs so they can store and share data. This includes iSCSI, NFS, and other storage systems vendors and cloud providers provide

What is a Persistent Volume?

A Kubernetes persistent volume (PV) is a portion of physical Storage attached to Pods so that they can store data that remains available after the Pod is terminated or restarted. This type of Storage is ideal for applications that need to share data between Pods or that must survive restarts.

A PV can be created statically or dynamically by a cluster administrator. When a user makes a PersistentVolumeClaim (PVC), the cluster attempts to find PVs that match the PVC and binds them together. This practice is generally preferable to creating static PVs because it avoids the overhead of consuming Storage in this manner.

In some cases, however, using persistent volume in Kubernetes can be problematic for cluster administrators. When a cluster cannot match a user's PVC with any of the static PVs the administrator created, the group will try to dynamically provision a volume, especially for that user's PVC.

For this purpose, the cluster uses a StorageClass resource. Each StorageClass identifies volumes that belong to it and is described by parameters such as storage capacity, iopsPerGB, or the zone. These parameters can be arbitrary and may be different depending on the provider.

When the DefaultStorageClass admission plugin is enabled, a PVC does not need to specify a StorageClassName. Instead, the control plane identifies any existing PVCs without this key and updates them to set their storageClassName to match the default StorageClass.

Persistent Volume Claims

Persistent volume claims (PVCs) are a mechanism for requesting persistent volumes on Kubernetes clusters. They allow developers to dynamically request storage resources defined by StorageClasses, which indicate properties of storage devices such as performance, service levels, and backup policies.

PVCs are a more convenient way for developers to access Storage than cloud volumes, nfs, and other types of persistent books, which require many storage details to be understood before the Pod can use them. Moreover, they allow containers to use the exact PVC specification across different clusters and environments.

The PVC pattern is also easier to understand than the traditional approach of requesting a specific cloud storage provider. Developers can know the complete storage details and ask for enough space to meet the application requirements.

In addition, it's more convenient to deploy stateful applications using PVCs because they can be scaled up automatically. In particular, they can be used to create replica Pods that automatically get their PersistentVolumeClaims when a new pod is deployed.

When a PersistentVolumeClaim is bound, Kubernetes looks for a PV that matches the claim requirements and then mounts it to the Pod. Depending on the volume type, it can be mounted as read-only or read-write. If the volume supports multiple access modes, the user specifies which mode they want to use when claiming it with PVC.

Persistent Volumes

Persistent volumes (PVs) are a part of the Storage provided to Kubernetes clusters by administrators. They provide a way for containers running in PODs to attach to physical Storage to store data that they can share with other pods and still be accessible even after a pod is replaced.

The Persistent Volume API allows you to create PVs declaratively and define their properties in a YAML file. In this YAML, you can indicate the capacity of the PV and its access mode. For example, you could request a 30 gigabyte (GiB) PV mounted once read-write or often read-only.

You can also use Persistent Volume Claims to create and bind PV resources. These claims can request a specific size, access mode, and StorageClass for the volume. When the PersistentVolumeClaim satisfies all requirements, it is bound to the PV resource.

Claims can also request resource quotas to control the amount of memory, processing, or storage containers they can consume. They can specify these quotas in a matchLabels or matchExpressions field.

In some platforms, claims can also include a quality of service (QoS) parameter to ensure that the volume is assigned the best persistent Storage for the particular workload. This is a good practice, especially when using high-bandwidth services.

When you create a PersistentVolumeClaim, Kubernetes will automatically provide an appropriate Compute Engine persistent disk. This is usually done with the default StorageClass in the cluster. You can change the default StorageClass by setting it to a value other than the one created.

Persistent Volume Reclaim Policy

Kubernetes persistent volumes (PVs) provide Storage for applications deployed in a Kubernetes cluster to store data for a long time. Regular books erase the data if shut down, but a PV is independent of pod lifecycles and can remain in place for long periods.

PVs can be backed by physical disks or file systems on-premise or by cloud storage resources li. They are created with an API object that identifies implementation details like volume ID and name, as well as properties that describe how the volume is laid out and what size it has.

In addition to defining these properties, PVs can specify how they should be mounted by other nodes, such as whether they should be read-only or write-once. Additionally, they can set a storage policy that captures the storage requirements for the application and how they want Kubernetes to provision and allocate the volume within its data store.

The control plane reclaims any unbound PVCs with an empty storageClassName key or whose storageClassName does not match the default StorageClass. It then updates the corresponding PVCs to use this default StorageClass.

For dynamic storage provisioning, PVCs should be bound to Storage Classes that can create persistent volumes, and the storage class should include the minimum resource that the PVC requires. For example, if the PVC request requires 50 GB of Storage, a storage class should have at least 100 GB capacity.

© 2019-2023 Mike Gingerich Global, LLC    Contact   -   Privacy

magnifiermenu linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram