Creating Static PersistentVolumes
What you'll learn: How to manually define a PersistentVolume manifest that points to pre-provisioned storage in your infrastructure.
Understanding Static Provisioning
Static PersistentVolumes are storage resources you manually create by writing YAML manifests. Think of it like listing a rental property—you already own the storage (a disk, NFS share, etc.), and now you're creating a Kubernetes resource that describes it so Pods can "rent" it through PersistentVolumeClaims.
Unlike dynamic provisioning (which you'll learn later), you're responsible for creating both the actual storage backend and the PV object that represents it in Kubernetes.
Defining a Static PV Manifest
A static PV manifest requires three key sections:
1. Capacity: How much storage the volume provides
capacity:
storage: 10Gi
2. Access Modes: How the volume can be mounted (from the modes you learned: ReadWriteOnce, ReadOnlyMany, or ReadWriteMany)
accessModes:
- ReadWriteOnce
3. Backend Storage Configuration: Details about the actual storage system
nfs:
server: 192.168.1.100
path: /mnt/data
Complete Example
apiVersion: v1
kind: PersistentVolume
metadata:
name: my-static-pv
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
volumeMode: Filesystem
nfs:
server: 192.168.1.100
path: /mnt/data
The backend section (nfs here) varies based on your storage type—it could be hostPath, iscsi, cephfs, or many others. You must ensure the storage actually exists before creating the PV.
Key Takeaway: Static PersistentVolumes are manually-defined Kubernetes resources that describe pre-provisioned storage, specifying capacity, access modes, and backend configuration to make existing storage available for PVC binding.