DEV Community

Cover image for Kubernetes Pod Stuck in Terminating: Safe & Force Delete Guide
kkkevin
kkkevin

Posted on Originally published at opshubs.space

Kubernetes Pod Stuck in Terminating: Safe & Force Delete Guide

A Pod stuck in Terminating for minutes or hours usually means Kubernetes is waiting on one of three things: a container ignoring SIGTERM, an unreachable worker node, or a lingering finalizer that never cleared.

30-Second kubectl Diagnosis

# 1. Inspect finalizers and deletionTimestamp
kubectl get pod  -n  -o jsonpath='{.metadata.finalizers}{"n"}'

# 2. Check if the Pod's node is NotReady or unreachable
kubectl get pod  -n  -o wide
kubectl get nodes
Enter fullscreen mode Exit fullscreen mode

How to Unstick the Pod (Safe First, Force Last)

  • Check terminationGracePeriodSeconds & PID 1 Signal Handling: If your container runs via a shell wrapper that swallows SIGTERM, Kubernetes waits the full grace period before sending SIGKILL (Exit Code 137). Use exec-form ENTRYPOINT ["app"].

  • Clear Stuck Finalizers (Only After Confirming Cleanup): If a controller or webhook deleted itself while leaving a finalizer behind, patch it out:

kubectl patch pod  -n  -p '{"metadata":{"finalizers":null}}' --type=merge
Enter fullscreen mode Exit fullscreen mode
  • Force Delete (Last Resort for Dead Nodes): Only use --force --grace-period=0 when you are certain the underlying container is no longer running (especially for StatefulSets with PVCs, to avoid split-brain writes):
kubectl delete pod  -n  --grace-period=0 --force
Enter fullscreen mode Exit fullscreen mode

Related guides: Investigate Exit Code 137 (SIGKILL) and Kubernetes QoS & Eviction Priority.

Originally published at OpsHubs. Found it useful? Buy us a coffee ☕.

Top comments (0)