Storage Troubleshooting Scenarios¶
Real-world storage troubleshooting scenarios for CKA exam preparation.
Scenario 1: PVC Stuck in Pending¶
Problem¶
$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
my-pvc Pending standard 5m
Diagnosis Steps¶
# 1. Describe PVC for events
kubectl describe pvc my-pvc
# 2. Check StorageClass
kubectl get storageclass
# 3. Check available PVs
kubectl get pv
# 4. Check provisioner pods
kubectl get pods -n kube-system | grep provisioner
Solutions¶
No matching PV available
StorageClass not found
Provisioner not working
Scenario 2: Pod Cannot Mount Volume¶
Problem¶
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
my-pod 0/1 ContainerCreating 0 5m
$ kubectl describe pod my-pod
Events:
Warning FailedMount Unable to attach or mount volumes
Diagnosis Steps¶
# 1. Check PVC is bound
kubectl get pvc
# 2. Check PV status
kubectl get pv
# 3. Check node where pod is scheduled
kubectl get pod my-pod -o wide
# 4. Check volume attachment
kubectl get volumeattachment
Solutions¶
PVC not bound
Volume already attached to another node
Node storage driver issue
Scenario 3: Volume Data Not Persisting¶
Problem¶
Data written to volume is lost after pod restart
Diagnosis Steps¶
# 1. Check volume mount in pod
kubectl get pod my-pod -o yaml | grep -A10 volumeMounts
# 2. Check PVC reclaim policy
kubectl get pv my-pv -o yaml | grep persistentVolumeReclaimPolicy
# 3. Verify data path
kubectl exec my-pod -- ls -la /data
Solutions¶
Using emptyDir instead of PVC
Wrong mount path
Reclaim policy is Delete
Scenario 4: Disk Pressure on Node¶
Problem¶
Diagnosis Steps¶
# 1. Check disk usage on node
ssh worker1 "df -h"
# 2. Check container images
ssh worker1 "sudo crictl images"
# 3. Check container logs size
ssh worker1 "sudo du -sh /var/log/containers/*"
Solutions¶
Clean old container logs
Remove unused volumes
Storage Debugging Commands¶
# Check PV/PVC status
kubectl get pv,pvc -A
# Describe for events
kubectl describe pvc my-pvc
kubectl describe pv my-pv
# Check StorageClass
kubectl get storageclass -o yaml
# Check CSI drivers
kubectl get csidrivers
# Check volume attachments
kubectl get volumeattachment
# Debug from inside pod
kubectl exec my-pod -- df -h
kubectl exec my-pod -- mount | grep /data