Kubernetes
Persistent Volume
PVC
Storage
Cloud Computing

Can we get Persistent Volume with only PVC without PV in k8s?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Understanding Persistent Volume Claims in Kubernetes

Kubernetes is widely known for its robust system of managing containerized applications, but the platform also includes complex storage solutions that sometimes appear confusing at a first glance. One of the most common questions among Kubernetes users is whether it is possible to obtain a Persistent Volume (PV) using only a Persistent Volume Claim (PVC), without explicitly creating or defining a PV. Let's explore the technical details behind this and see how Kubernetes simplifies storage provisioning with features like dynamic provisioning.

The PVC/PV Relationship

In Kubernetes, storage solutions are abstracted by two main concepts:

  • Persistent Volume (PV): A piece of storage in the cluster with a lifecycle independent of any individual pod that uses the PV. It is defined by an admin using a variety of storage backends.
  • Persistent Volume Claim (PVC): A request for storage by a user. This request allows users to use abstract storage without needing to know the specific details of the backends or the PVs.

Traditionally, an administrator would first create a PV and then a user would claim storage by creating a PVC that binds to a pre-existing PV.

Dynamic Provisioning

Kubernetes simplifies storage management through a feature called Dynamic Provisioning. This provision method allows users to create PVCs that automatically provision a PV, abstracting the administration layer and simplifying operations.

How Dynamic Provisioning Works

  1. StorageClass Definition: Administrators define a `StorageClass` which specifies the provisioner (e.g., AWS EBS, GCE PD, NFS), parameters, and reclaim policies.
    • ReadWriteOnce
    • ReadWriteOnce
  • Reclaim Policy: Defined in `StorageClass`, it determines what happens to a PV after its released. Normally set to `Retain`, `Recycle`, or `Delete`.
  • StorageClass Parameters: The specific parameters for cloud providers or provisioners, such as volume type or zone, must be configured correctly to use dynamic provisioning effectively.
  • Access Modes: Defines how a PV can be mounted by pods (ReadWriteOnce, ReadWriteMany).

Course illustration
Course illustration

All Rights Reserved.