kubernetes
config_error
ai_generated
true
persistentvolumeclaim is stuck in Pending state: no storage class specified
ID: kubernetes/persistentvolumeclaim-stuck-pending-no-storageclass
88%Fix Rate
87%Confidence
1Evidence
2023-09-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Kubernetes v1.26.6 | active | — | — | — |
| Kubernetes v1.27.4 | active | — | — | — |
| Kubernetes v1.28.1 | active | — | — | — |
Root Cause
A PersistentVolumeClaim (PVC) is stuck in Pending state because it doesn't specify a storageClassName and the cluster has no default StorageClass configured.
generic中文
持久卷声明(PVC)卡在Pending状态,因为它没有指定storageClassName,并且集群没有配置默认的StorageClass。
Official Documentation
https://kubernetes.io/docs/concepts/storage/persistent-volumes/#storageclassesWorkarounds
-
85% success Check existing StorageClasses: `kubectl get storageclass`. If none is set as default, set one: `kubectl patch storageclass <name> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'`
Check existing StorageClasses: `kubectl get storageclass`. If none is set as default, set one: `kubectl patch storageclass <name> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'` -
90% success Update the PVC to specify an existing storage class: `kubectl edit pvc <pvc-name>` and add `spec.storageClassName: <existing-class-name>`
Update the PVC to specify an existing storage class: `kubectl edit pvc <pvc-name>` and add `spec.storageClassName: <existing-class-name>`
中文步骤
Check existing StorageClasses: `kubectl get storageclass`. If none is set as default, set one: `kubectl patch storageclass <name> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'`Update the PVC to specify an existing storage class: `kubectl edit pvc <pvc-name>` and add `spec.storageClassName: <existing-class-name>`
Dead Ends
Common approaches that don't work:
-
Manually create a PersistentVolume (PV) with the same size
75% fail
Without a storage class, the PVC won't bind to a manually created PV unless the PV has the exact same label and access modes, and the PVC doesn't specify a selector. It's easier to configure a StorageClass.
-
Delete and recreate the PVC with a random storageClassName
90% fail
Using a random or non-existent storage class name will still result in Pending state. The storage class must exist and be configured correctly.