Skip to Content
Asterrr's Handbook
Cheat sheets

Storage

Volume types, access modes, reclaim policies, binding rules, StorageClass fields and the manifests for PVs, PVCs and classes.

Pick the volume

NeedUseLifetime
Scratch space shared in a PodemptyDir (medium: Memory for tmpfs)The Pod
Config or credentials as filesconfigMap, secret, projectedFollows the object
A file or socket on the nodehostPathThe node
Data that outlives PodspersistentVolumeClaimSet by the reclaim policy
Per-replica disksStatefulSet volumeClaimTemplatesKept after scale-down

Access modes

ModeMeaning
ReadWriteOnce (RWO)Read-write by one node. Several Pods on that node can share it
ReadOnlyMany (ROX)Read-only by many nodes
ReadWriteMany (RWX)Read-write by many nodes. Needs NFS, CephFS or similar
ReadWriteOncePod (RWOP)Read-write by exactly one Pod

Binding rules

A claim binds to one PV that matches class, access modes, volume mode and capacity at least the request, and the selector if present. Binding is 1:1 and a bound PV shows its full size. storageClassName: "" means no class and no dynamic provisioning. Omitting the field uses the default class.

Reclaim policy

PolicyAfter the claim is deleted
RetainPV becomes Released, data kept. Clear spec.claimRef to reuse it
DeletePV and backing volume removed. Default for dynamic PVs
RecycleRemoved from use, do not choose it

StorageClass fields

FieldValues and effect
provisionerThe CSI driver name, or kubernetes.io/no-provisioner for static PVs
volumeBindingModeImmediate, or WaitForFirstConsumer to provision where the Pod schedules
reclaimPolicyDelete (default) or Retain, copied to new PVs
allowVolumeExpansionMust be true to grow a claim, and it cannot shrink
parameters, mountOptionsDriver specific
Default classAnnotation storageclass.kubernetes.io/is-default-class: "true"

Manifests

apiVersion: v1
kind: PersistentVolume
metadata: { name: pv-data }
spec:
  capacity: { storage: 10Gi }
  accessModes: [ReadWriteOnce]
  persistentVolumeReclaimPolicy: Retain
  storageClassName: manual
  hostPath: { path: /mnt/data }
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata: { name: data }
spec:
  accessModes: [ReadWriteOnce]
  storageClassName: manual
  resources: { requests: { storage: 5Gi } }
volumes: [{ name: data, persistentVolumeClaim: { claimName: data } }]

Commands

k get pv,pvc,sc, k describe pvc data (Events show why it is Pending), k patch pv x -p '{"spec":{"claimRef":null}}', k patch pvc data -p '{"spec":{"resources":{"requests":{"storage":"20Gi"}}}}', k get csidrivers.

On this page