Course contentsShow
← Software Engineering
Lesson 1459 of 1,93342. Containerization and OrchestrationFree lesson

Persistent Volumes and Claims

Managing stateful workloads with PersistentVolumes, PersistentVolumeClaims, and StorageClasses.

Persistent Volumes and Claims

What you'll learn: How to manage stateful workloads in Kubernetes by separating storage provisioning from storage consumption using PersistentVolumes, PersistentVolumeClaims, and StorageClasses.

The Problem with Ephemeral Storage

You already know that Pods are ephemeral—when they restart, their local storage disappears. For stateless applications, this is fine. But what about databases, file uploads, or any data that must survive Pod restarts? That's where persistent storage comes in.

The Three-Layer Storage Model

Kubernetes separates storage concerns into three abstractions:

PersistentVolume (PV): A cluster-level storage resource provisioned by an administrator or dynamically created. Think of it as an actual hard drive available in your cluster—it exists independently of any Pod.

PersistentVolumeClaim (PVC): A user's request for storage. Your Pod doesn't directly reference a PV; instead, it requests storage through a PVC (specifying size and access mode). Kubernetes then binds an appropriate PV to satisfy that claim.

StorageClass: A template defining how to dynamically provision storage (e.g., AWS EBS, Google Persistent Disk, NFS). When a PVC references a StorageClass, Kubernetes automatically creates a matching PV on-demand.

The Analogy

Think of it like hotel room booking: the hotel has rooms (PVs), you make a reservation requesting specific amenities (PVC), and the hotel booking system (StorageClass) determines which type of room to assign based on your requirements.

Why This Matters

This separation allows developers to request storage without knowing infrastructure details, while administrators control the actual storage backends. Your Pods reference PVCs in their volume specifications, and those claims bind to appropriate PVs—automatically if using StorageClasses.

Key Takeaway: PersistentVolumes decouple storage provisioning from consumption, enabling stateful workloads to survive Pod restarts while maintaining infrastructure abstraction through PersistentVolumeClaims and dynamic provisioning via StorageClasses.