Tuesday, June 9, 2026

K8S Reference - PersistentVolume (PV) YAML

The following table explains the major fields used when defining a PersistentVolume (PV) in Kubernetes.

Element Required / Optional Description Example Syntax
apiVersion Required Specifies the Kubernetes API version. For PersistentVolumes, this is typically v1.
apiVersion: v1
kind Required Defines the Kubernetes resource type being created.
kind: PersistentVolume
metadata.name Required Unique name used to identify this PersistentVolume inside the cluster.
name: supavolume
spec.capacity.storage Required Total storage capacity exposed by this volume.
storage: 10Gi
spec.accessModes Required Determines how the storage can be mounted by nodes and Pods.
- ReadWriteOnce
spec.<storage-source> Required Defines the actual storage backend. Exactly one storage plugin must be chosen.
hostPath:
  path: "/mnt/data"
spec.storageClassName Optional (Recommended) Associates the PV with a particular StorageClass and enables PVC matching.
storageClassName: manual
spec.persistentVolumeReclaimPolicy Optional (Recommended) Controls what happens to the underlying storage after the PVC is deleted.
persistentVolumeReclaimPolicy: Retain
spec.volumeMode Optional Determines whether the volume is mounted as a filesystem or exposed as a raw block device.
volumeMode: Filesystem
Important: A PersistentVolume must define exactly one storage backend such as hostPath, nfs, csi, awsElasticBlockStore, azureDisk, or another supported storage plugin.

No comments:

Post a Comment

K8S - Important Reference Articles on this Blog

The following articles provide a neat and concise reference for creating YAML files for some of the most commonly use...