Interview Prep/Real-World Interview/Kubernetes cluster-level

After a node was terminated, its pods have shown `Terminating` for two hours and their replacements aren't being created.

IntermediateTroubleshootingKubernetes cluster-level
Answer

Likely causes → No kubelet is left to confirm the containers stopped, so the API keeps the pod objects. Deployments usually replace them anyway, but StatefulSet pods with the same name (db-0) can't be recreated until the old object is gone. A Node object that still exists also blocks cleanup.

Diagnose →

kubectl get pods -A -o wide | grep Terminating
kubectl get node <dead-node>
kubectl get pod db-0 -o jsonpath='{.metadata.finalizers}'

Fix → First confirm the node is really gone (otherwise two copies of a StatefulSet pod could write the same data). Then delete the Node object, or force delete the pods:

kubectl delete node ip-10-0-3-17.ec2.internal
kubectl delete pod db-0 --grace-period=0 --force

Prevent → Make sure the cloud controller manager removes Node objects for terminated instances, and use the node.kubernetes.io/out-of-service taint for non-graceful node shutdown on bare metal.

All Real-World Interview questions Roadmap: Interview readiness

More on Kubernetes cluster-level