Interview Prep/Kubernetes/Resources, OOM, probes and termination

A Pod is stuck in `Terminating` for 30 minutes after `kubectl delete pod`.

IntermediateTroubleshootingResources, OOM, probes and termination
Answer

Likely causes → (1) The node is down or the kubelet is unreachable, so nobody confirms the containers stopped. (2) A finalizer in metadata.finalizers that a controller never removes. (3) A volume that cannot be unmounted.

Diagnose →

kubectl get pod web-x -o jsonpath='{.metadata.finalizers}{"\n"}{.spec.nodeName}{"\n"}'
kubectl get node $(kubectl get pod web-x -o jsonpath='{.spec.nodeName}')
kubectl describe pod web-x | sed -n '/Events/,$p'

Fix → Node dead: delete or recover the Node object; the Pod is then garbage collected. Stale finalizer: fix the owning controller, or as a last resort remove it:

kubectl patch pod web-x -p '{"metadata":{"finalizers":null}}' --type=merge

kubectl delete pod web-x --grace-period=0 --force only removes the API object; the container may still run on the node.

Prevent → Monitor node health and controllers that own finalizers; avoid force deletes for StatefulSets.

All Kubernetes questions Roadmap: Kubernetes core

More on Resources, OOM, probes and termination