Skip to content
Latchkey

Kubernetes Pod Stuck "Terminating" - Fix Finalizers and Stuck Deletes in CI

A pod enters Terminating when deletion starts, but it only disappears once its containers stop and all finalizers are removed. It hangs when a finalizer never clears, the process ignores SIGTERM past the grace period, or the node is unreachable.

What this error means

A pod shows STATUS: Terminating long past its terminationGracePeriodSeconds and a CI step waiting on its deletion hangs. kubectl get pod -o yaml still lists a metadata.deletionTimestamp and often a lingering metadata.finalizers entry.

kubectl output
$ kubectl get pod api-...
NAME       READY   STATUS        RESTARTS   AGE
api-...    1/1     Terminating   0          12m
# metadata.finalizers: ["example.com/cleanup"]  ← never removed

Common causes

A finalizer never clears

A controller/operator finalizer (e.g. a cleanup hook) is responsible for removing itself after teardown. If that controller is down or erroring, the finalizer stays and the pod cannot be removed.

Process ignores SIGTERM

The container does not handle SIGTERM and runs until the grace period, then is SIGKILLed - but if PID 1 reaps improperly or hangs, termination drags out.

Node unreachable

If the node hosting the pod is NotReady/unreachable, the control plane cannot confirm the containers stopped, so the pod sits in Terminating until the node recovers or is removed.

How to fix it

Identify what is holding deletion

Check for a stuck finalizer and the node’s health before forcing anything.

Terminal
kubectl get pod <pod> -o jsonpath='{.metadata.finalizers}'; echo
kubectl get pod <pod> -o jsonpath='{.spec.nodeName}'; echo
kubectl get nodes

Clear the real blocker, not just force-delete

  1. If a finalizer is stuck, restore the controller that owns it so it removes the finalizer cleanly.
  2. If the node is unreachable, recover or remove the node so the control plane can finalize deletion.
  3. Fix the app to handle SIGTERM so it shuts down within the grace period.

How to prevent it

  • Handle SIGTERM in apps so they exit within terminationGracePeriodSeconds.
  • Keep finalizer-owning controllers/operators healthy so finalizers clear on delete.
  • Monitor node health so unreachable nodes are remediated quickly.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →