Kubernetes
Persistent Volume
PVC
Storage
Cloud Computing

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

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

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).

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.