kubectl Volumes commands
28 commands in 3 groups: PersistentVolumes, PersistentVolumeClaims, StorageClass. Click or tap any command to copy it. Official documentation: kubernetes.io.
Open in the interactive cheat sheet search, stars and every other section
PersistentVolumes
Cluster-wide storage resources provisioned by admins. Created via manifests only, as there is no imperative create command.
kubectl apply -f pv.yaml
Create or update a PersistentVolume
kubectl delete pv <name>
Delete a PersistentVolume
kubectl describe pv <name>
PV details, capacity, claim, and status
kubectl edit pv <name>
Edit PV in-place
kubectl get pv
List all PersistentVolumes
kubectl get pv -o wide
PVs plus the VolumeMode column
kubectl get pv <name> -o yaml
Get PV manifest as YAML
kubectl patch pv <name> -p '{"spec":{"persistentVolumeReclaimPolicy":"Retain"}}'
Change reclaim policy to Retain
PersistentVolumeClaims
Request and bind storage for workloads. Includes fix for PVCs stuck in Terminating state.
kubectl apply -f pvc.yaml
Create or update a PVC from manifest
kubectl delete pvc <name>
Delete a PVC
kubectl delete pvc <name> --wait=false
Delete PVC without waiting (non-blocking)
kubectl describe pvc <name>
PVC details, bound PV and events
kubectl edit pvc <name>
Edit PVC in-place
kubectl get pvc
List PVCs in current namespace
kubectl get pvc -A
All PVCs across namespaces
kubectl get pvc -n <namespace>
PVCs in a specific namespace
kubectl get pvc <name> -o yaml
Get PVC manifest as YAML
kubectl patch pvc <name> -p '{"metadata":{"finalizers":null}}'
Remove finalizers to unblock stuck Terminating PVC
kubectl patch pvc <name> -p '{"spec":{"resources":{"requests":{"storage":"10Gi"}}}}'
Expand PVC to a larger size (needs allowVolumeExpansion)
StorageClass
Define dynamic storage provisioners. Set or change the default StorageClass for the cluster.
kubectl annotate sc <name> storageclass.kubernetes.io/is-default-class=true --overwrite
Mark StorageClass as default
kubectl apply -f storageclass.yaml
Create or update a StorageClass
kubectl delete sc <name>
Delete a StorageClass (short alias)
kubectl delete storageclass <name>
Delete a StorageClass
kubectl describe storageclass <name>
StorageClass details and provisioner
kubectl edit storageclass <name>
Edit StorageClass in $EDITOR
kubectl get sc
Short alias for get storageclass
kubectl get storageclass
List all StorageClasses
kubectl get sc <name> -o yaml
Get StorageClass manifest as YAML