| name | debugging-k8s-storage |
| description | Debugs Kubernetes storage issues including PVC stuck in Pending, PV binding failures, volume mount errors, and StorageClass problems. Use when volumes fail to mount, PVCs not binding, or storage-related pod failures. |
| allowed-tools | Bash |
Debugging Kubernetes Storage
Investigates PersistentVolumeClaim, PersistentVolume, and mount issues.
Common Storage Issues
| Symptom | Likely Cause | First Check |
|---|
| PVC Pending | No matching PV, StorageClass issue | PVC events |
| Mount failed | PV not available, node issue | Pod events |
| Multi-attach error | RWO volume on multiple nodes | Access mode |
| Permission denied | fsGroup/runAsUser mismatch | Security context |
Investigation Workflow
Step 1: Check PVC Status
kubectl get pvc -n <ns>
kubectl describe pvc <pvc> -n <ns>
PVC Pending? Check Events section for reason.
Step 2: Check PV Binding
kubectl get pv
kubectl describe pv <pv-name>
PVC binds to PV when:
- StorageClass matches (or empty for static)
- Access modes compatible
- Capacity sufficient
Step 3: Check StorageClass
kubectl get storageclass
kubectl get storageclass -o jsonpath='{range .items[?(@.metadata.annotations.storageclass\.kubernetes\.io/is-default-class=="true")]}{.metadata.name}{end}'
kubectl describe storageclass <name>
Step 4: Check Pod Mount Events
kubectl describe pod <pod> -n <ns> | grep -A10 "Events:"
kubectl get events -n <ns> --field-selector involvedObject.name=<pvc>
Specific Issues
PVC Stuck in Pending
Common reasons:
- No matching PV (static provisioning)
- StorageClass can't provision (dynamic provisioning)
- Capacity not available
- Wrong access mode
kubectl get pvc <pvc> -n <ns> -o yaml | grep -A5 "spec:"
kubectl describe pvc <pvc> -n <ns> | grep -A10 "Events:"
Multi-Attach Error
kubectl get pvc <pvc> -n <ns> -o jsonpath='{.spec.accessModes}'
kubectl get pod -n <ns> -o wide
RWO volumes can only attach to one node. If pods are on different nodes, one will fail.
Options:
- Use ReadWriteMany (RWX) if storage supports it
- Ensure pods schedule to same node
Volume Mount Timeout
kubectl get pod <pod> -n <ns> -o jsonpath='{.spec.nodeName}'
kubectl describe node <node> | grep -A5 "Conditions:"
May indicate:
- Cloud provider API issues
- Node can't reach storage backend
- CSI driver problems
Permission Denied on Volume
kubectl get pod <pod> -n <ns> -o jsonpath='{.spec.securityContext}'
kubectl get pod <pod> -n <ns> -o jsonpath='{.spec.containers[*].securityContext}'
Fix with fsGroup or runAsUser in pod spec.
Quick Debug Commands
kubectl get pvc,pv -A
kubectl get csidrivers
kubectl get events -A --field-selector reason=FailedMount
kubectl get events -A --field-selector reason=FailedAttachVolume
Access Modes Reference
| Mode | Short | Description |
|---|
| ReadWriteOnce | RWO | Single node read-write |
| ReadOnlyMany | ROX | Multiple nodes read-only |
| ReadWriteMany | RWX | Multiple nodes read-write |
| ReadWriteOncePod | RWOP | Single pod read-write |
Notes
- Load
debugging-k8s-pods if pod has other issues besides storage
- Load
analyzing-k8s-events for storage event timeline