Skip to content

StatefulSet pod stuck in Terminating because the node is gone

Storagetested on k0s v1.36.6, LINSTOR 1.34.2, linstor-csi v1.12.0

If a node fails and stays away, Kubernetes marks its pods for deletion after five minutes. But only that node's kubelet can delete them. A StatefulSet starts no replacement, because there must never be two pg-0.

Symptom

kubectl get node k0s-w2 | cut -c1-19
kubectl -n demo get pod pg-0 -o wide | cut -c1-90
NAME     STATUS
k0s-w2   NotReady
NAME   READY   STATUS        RESTARTS      AGE   IP            NODE
pg-0   1/1     Terminating   1 (10m ago)   15m   10.244.1.82   k0s-w2

After five minutes (tolerationSeconds: 300) Kubernetes marks the pod for deletion. It stays in Terminating as long as the kubelet on the node can't be reached.

Diagnosis

At the DRBD level: the isolated Primary has lost quorum and suspends all writes. The second replica would have the majority together with the witness – but nobody uses the volume there.

ssh k0s-w2 "sudo drbdsetup status --verbose $R | head -1"
ssh k0s-w3 "sudo drbdadm status $R"
pvc-11dccaf7-... node-id:1 role:Primary suspended:quorum
pvc-11dccaf7-... role:Secondary
  disk:UpToDate open:no
  k0s-ctrl role:Secondary
    peer-disk:Diskless peer-client:yes
  k0s-w2 connection:Connecting

Causes

kubelet goneOnly the node's kubelet may delete the pod

The pod is marked for deletion, but the kubelet on the dead node never confirms it. Kubernetes doesn't know whether the old instance is still writing.

StatefulSetThere must never be two pg-0

A StatefulSet starts no replacement while the old pod exists. The confirmation "this node is dead" is the out-of-service taint.

Fix

Set the taint once the node is definitely off. In the course the database ran on k0s-w3, the node with the second replica, 15 seconds later. When the node comes back, remove the taint – it also evicted linstor-csi-node.
kubectl taint node k0s-w2 node.kubernetes.io/out-of-service=nodeshutdown:NoExecute
kubectl -n demo wait --for=condition=Ready pod/pg-0 --timeout=180s
kubectl -n demo get pod pg-0 -o wide | cut -c1-90
node/k0s-w2 tainted
pod/pg-0 condition met
pg-0   1/1     Running   0          6s    10.244.0.77   k0s-w3

Don't: Setting the taint while the node is still alive. DRBD quorum then protects against double writes, but the application there gets I/O errors.

▶
Break it yourself and find it – free
k0s and LINSTOR hands-on, day 10: planned maintenance, a crash and a node that doesn't come back – with the out-of-service taint and measured downtime.
Go to day 10 →

FAQ

What happens when the node comes back?

force-secondary demotes the old Primary, the other replica's data wins. The kubelet can only unmount the device once linstor-csi-node runs there again – that is, after the taint is removed.

How long was the database down in the course?

Just under seven minutes (6:47), of which five minutes were waiting for the toleration and 21 seconds after the taint.

Related error patterns

More