Home KubernetesKubernetes Persistent Storage: PV, PVC, and StorageClass Explained

Kubernetes Persistent Storage: PV, PVC, and StorageClass Explained

by Knowledge Base Linux
Kubernetes Persistent Storage — Kubernetes Persistent Storage: PV, PVC, and StorageClass Explained

Containers are designed to be disposable, but data is not. Delete a pod running a database and, without persistent storage, its data dies with it. Kubernetes solves this with a three-layer storage model built around the Kubernetes Persistent Volume PVC StorageClass objects. If the acronyms have always blurred together, this guide separates them cleanly: how a Kubernetes Persistent Volume PVC StorageClass chain works, how to request storage with a claim, and how dynamic provisioning removes most of the manual work.

The Three Objects: Kubernetes Persistent Volume PVC StorageClass – Kubernetes Persistent Storage

  • PersistentVolume (PV) — a piece of storage in the cluster: an NFS share, a cloud disk, an iSCSI target. It exists independently of any pod, like a physical hard drive sitting in a rack.
  • PersistentVolumeClaim (PVC) — a request for storage by a user or application: “I need 10 GiB, readable and writable by one node.” Pods mount claims, never volumes directly.
  • StorageClass — a template describing the kind of storage (fast SSD, standard disk, encrypted) and which provisioner creates it. It enables dynamic provisioning: a matching PV is created automatically when a claim appears.

The analogy that helps: a PV is an apartment, a PVC is a rental application specifying size and terms, and a StorageClass is the property agency that can build a new apartment to order when none is free.

Static Provisioning: Define a Kubernetes Persistent Volume PVC StorageClass Manually – Kubernetes Persistent Storage

First, an administrator creates a PV. This example uses an NFS export:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: data-pv
spec:
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  nfs:
    path: /exports/data
    server: 192.168.1.20

Then the application requests it with a PVC:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: data-pvc
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi

Kubernetes binds the claim to a suitable PV — one with enough capacity and a compatible access mode. Check the result with kubectl get pv,pvc: both objects should show the status Bound, which confirms the claim has been successfully matched with the volume.

https://kblinux.com/wp-content/uploads/2026/10/media-generation-k8s-storage-claim-0-ffc27b82-fe61-4903-b587-fdbc4471d69b.webp

Dynamic Provisioning with a Kubernetes Persistent Volume PVC StorageClass

On cloud clusters and most modern installations you never write a PV by hand. You name a StorageClass in the claim, and the provisioner creates the disk for you:

kubectl get storageclass
NAME                 PROVISIONER
standard (default)   k8s.io/minikube-hostpath
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: fast-data
spec:
  storageClassName: standard
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi

Moments later a brand-new PV exists and the claim is Bound. When the claim is deleted, the default reclaim policy (Delete) removes the volume and its data too — set Retain on anything you cannot afford to lose.

Use the Claim in a Pod

A pod references the PVC by name and mounts it like any other volume:

apiVersion: v1
kind: Pod
metadata:
  name: db
spec:
  containers:
  - name: db
    image: mariadb:11
    volumeMounts:
    - name: data
      mountPath: /var/lib/mysql
  volumes:
  - name: data
    persistentVolumeClaim:
      claimName: fast-data

Now delete and recreate the pod: the new pod mounts the same claim and the database files are still there. Stateful workloads normally use StatefulSets, which generate one PVC per replica automatically from a volumeClaimTemplates section. Configuration for such apps is typically injected separately — see our guide to the Kubernetes ConfigMap and Secret objects.

Access Modes Explained

  • ReadWriteOnce (RWO) — one node can mount it read-write. The default for block storage and most databases.
  • ReadOnlyMany (ROX) — many nodes can mount read-only, useful for shared static content.
  • ReadWriteMany (RWX) — many nodes can write simultaneously. Requires NFS, CephFS, or a cloud file service; most block devices cannot do this.
  • ReadWriteOncePod (RWOP) — restricts mounting to a single pod, for workloads that must never be double-mounted.

The most common beginner failure is asking for RWX from a provisioner that only supports RWO: the claim stays Pending forever.

Troubleshooting Storage Problems

  • PVC stuck in Pending: no PV matches and dynamic provisioning failed. Run kubectl describe pvc — events will name the StorageClass or provisioner error. Also confirm the named StorageClass exists.
  • Pod stuck in ContainerCreating with mount errors: often a volume already attached to another node (RWO), or wrong NFS permissions.
  • Data gone after claim deletion: the reclaim policy was Delete. For important volumes set Retain, or snapshot volumes before deleting claims.
  • Out of capacity: a PVC can be expanded if its StorageClass sets allowVolumeExpansion: true — edit the claim’s requested storage and restart the pod.

The debugging commands used above are part of our kubectl commands cheat sheet.

Conclusion

The Kubernetes Persistent Volume PVC StorageClass model separates three concerns: administrators supply volumes or provisioners, StorageClasses describe the tiers of storage on offer, and applications simply claim what they need. Once you think in claims instead of disks, stateful applications on Kubernetes become predictable — pods come and go, data stays. For provisioner-specific options and volume snapshot APIs, the official persistent volumes documentation is the authoritative reference.

You may also like

KbLinux

Typically replies within a day

Hello, Welcome to the site. Please click below button for chatting me through Telegram.