PV Capacity and Storage Requests
What You'll Learn
You'll learn how to specify the amount of storage a PersistentVolume offers and how to request a specific amount in a PersistentVolumeClaim.
Understanding Storage Capacity
When you create a PersistentVolume (PV), you must declare how much storage it provides. Similarly, when a Pod needs storage through a PersistentVolumeClaim (PVC), you specify how much storage you're requesting. Think of this like renting storage units: the facility (PV) advertises unit sizes, and you (PVC) request a specific amount of space you need.
PV Capacity Specification
In a PV manifest, you define capacity under the spec.capacity.storage field. This tells Kubernetes the total size of the storage resource:
apiVersion: v1
kind: PersistentVolume
metadata:
name: my-pv
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
This PV advertises 10 gigabytes of available storage.
PVC Storage Requests
When creating a PVC, you specify how much storage you need under spec.resources.requests.storage:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
This PVC requests 5 gigabytes. During the binding process, Kubernetes will match this PVC with a PV that has at least 5Gi available and compatible access modes.
Matching Logic
A PVC requesting 5Gi can bind to a PV offering 10Gi, but not to one offering only 3Gi. You get the entire PV—you can't split a 10Gi PV among multiple 5Gi claims.
Key Takeaway: PV capacity declares the storage size available, while PVC requests specify the minimum storage needed; Kubernetes binds PVCs to PVs with sufficient capacity and matching access modes.