Occasionally you may run into a pod that is hung in
Terminating state. Sometimes this pod may be on an unresponsive node or just doesn't exist anymore, but the kube api server doesn't know yet.
To forcefully terminate the pod, I run through these steps. The last option is more of a final resort.
kubectl delete --wait=false pod <pod>
Terminate immediately, without grace-period
--grace-period=-1: Period of time in seconds given to the resource to terminate gracefully. Ignored if negative.
Set to 1 for immediate shutdown. Can only be set to 0 when --force is true (force deletion).
kubectl delete --grace-period=1 pod <pod>
Force the pod to be removed (most dangerous)
--force=false: Only used when grace-period=0. If true, immediately remove resources from API and bypass graceful
deletion. Note that immediate deletion of some resources may result in inconsistency or data loss and requires
kubectl delete --grace-period=0 --force pod <pod>
After this, the pod should no longer show up in
get pods, but be aware of the note above. If this pod was really still running on a node, it may continue to run without kubernetes knowing about it.