kubernetes storage_error ai_generated partial

PersistentVolumeClaim is stuck in Pending state

ID: kubernetes/persistent-volume-pending

Also available as: JSON · Markdown
80%Fix Rate
85%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
8 active

Root Cause

PVC can't find a matching PV. No StorageClass provisioner or no available storage.

generic

Workarounds

  1. 92% success Check if a default StorageClass exists: kubectl get storageclass
    kubectl get storageclass

    Sources: https://kubernetes.io/docs/concepts/storage/storage-classes/

  2. 88% success Create a StorageClass or set one as default if missing
    kubectl patch storageclass <name> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'

    Sources: https://kubernetes.io/docs/tasks/administer-cluster/change-default-storage-class/

  3. 80% success For local dev, use local-path provisioner or hostPath
    # Install local-path provisioner (for development):
    kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml
    
    # Or use hostPath (single-node only):
    kind: PersistentVolume
    spec:
      hostPath:
        path: /tmp/data
      storageClassName: manual

    Sources: https://kubernetes.io/docs/concepts/storage/volumes/#hostpath

Dead Ends

Common approaches that don't work:

  1. Manually create a PV with exact specs 55% fail

    Manual PVs don't scale and are hard to manage

  2. Delete and recreate the PVC 70% fail

    Won't help if the underlying issue is no StorageClass or no space

Error Chain

Frequently confused with: