Skip to content

PVC stuck in Pending: unbound immediate PersistentVolumeClaims

Kubernetestested on RKE2 v1.37.2

The Pod only says "unbound immediate PersistentVolumeClaims". The real answer is one station further: in the PVC's events and in the provisioner's log. Walk the chain Pod → PVC → PV → provisioner → node.

Symptom

kubectl -n tag10 get pod db
kubectl -n tag10 events --for pod/db | tail -1
NAME   READY   STATUS    RESTARTS   AGE
db     0/1     Pending   0          8s
8s          Warning   FailedScheduling   Pod/db   0/3 nodes are available: pod has
  unbound immediate PersistentVolumeClaims. not found

Pod and PVC are both Pending. The Pod only tells you that the PVC is not bound.

Diagnosis

One station further: the PVC, its events and the existing StorageClasses.

kubectl -n tag10 get pvc daten | cut -c1-80
kubectl -n tag10 describe pvc daten | sed -n '/^Events/,$p'
kubectl get storageclass | cut -c1-80
NAME    STATUS    VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS    VOLUMEATTRIBUTES
daten   Pending                                      local-storage   <unset>
Events:
  Type     Reason              Age              From                         Message
  ----     ------              ----             ----                         -------
  Warning  ProvisioningFailed  6s (x2 over 9s)  persistentvolume-controller
  storageclass.storage.k8s.io "local-storage" not found
NAME         PROVISIONER             RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUME
local-path   rancher.io/local-path   Delete          WaitForFirstConsumer   false

Causes

storageclass not foundThe StorageClass doesn't exist

The PVC asks for local-storage, but the class in this cluster is called local-path. A class that has been set is immutable.

no storage class is setNo class and no default StorageClass

The PVC names no StorageClass, and the cluster has no default StorageClass. Without a class, Kubernetes looks for a matching existing PV – and there is none.

Normal  FailedBinding  1s (x2 over 7s)  persistentvolume-controller  no persistent
volumes available for this claim and no storage class is set

WaitForFirstConsumerNot an error – the PVC waits for a Pod

local-path binds only once a Pod uses the PVC, and creates the volume on the node the Pod lands on. A PVC without a Pod stays Pending on purpose.

PersistentVolume's node affinityThe volume lives on another node

A local volume cannot move with the Pod. If its node is taken or ruled out by scheduling rules, the second Pod stays Pending.

21s (x2 over 21s)   Warning   FailedScheduling   Pod/web-76779759cc-mdhg5   0/3 nodes
  are available: 1 node(s) didn't match pod anti-affinity rules, 2 node(s) didn't match
  PersistentVolume's node affinity. preemption: ...
{"key":"kubernetes.io/hostname","operator":"In","values":["worker2"]}

Fix

A missing storageClassName may be set afterwards. A wrong one may not: delete the PVC and the Pod and recreate them with the right name – as long as there is no data in them yet.
kubectl -n tag10 delete pod db --wait=false
kubectl -n tag10 delete pvc daten
sed -i 's/local-storage/local-path/' klasse.yaml
kubectl apply -f klasse.yaml
kubectl -n tag10 wait pod/db --for=condition=Ready
kubectl -n tag10 get pvc daten | cut -c1-88
NAME    STATUS   VOLUME                                     CAPACITY   ACCESS MODES   ST
daten   Bound    pvc-2dcf8a8d-a00b-4484-82da-cc2f02d1af4c   1Gi        RWO            lo

Don't: Patching a StorageClass that is already set. Kubernetes rejects it – "spec is immutable after creation".

▶
Break it yourself and find it – free
Debugging Kubernetes, day 10: storage faults from a wrong StorageClass to an overflowing emptyDir, with a drill to reproduce each one.
Go to day 10 →

FAQ

What does ReadWriteOnce mean?

One node may mount the volume read-write, not one Pod. For "exactly one Pod" there is ReadWriteOncePod.

Where do I see what the provisioner does?

In its log, on RKE2 with kubectl -n local-path-storage logs deploy/local-path-provisioner. If creating the volume fails, it shows up there.

Related error patterns

More