Force-remove a stuck Terminating pod

Clear finalizers and force-delete a pod stuck in Terminating; first make sure the node is really gone

kubectl patch po <pod> -n <ns> -p '{"metadata":{"finalizers":null}}' --type=merge; kubectl delete po <pod> -n <ns> --grace-period=0 --force

tool
k8s-debug27 commands
tags
k8s-debugtroubleshootingk8s

More k8s-debug commands

  • kubectl get --raw /api/v1/nodes/<node>/proxy/stats/summary | jq '.pods[] | {name:.podRef.name, mem:.memory.workingSetBytes}'

    Get live memory per pod from the kubelet Summary API, without metrics-server

  • kubectl debug node/<node> -it --image=nicolaka/netshoot -- conntrack -S

    Check conntrack drop and insert_failed counters per CPU; a full nf_conntrack table drops packets

  • kubectl run dnstest --rm -it --image=nicolaka/netshoot --restart=Never -- dig +short <name>.<ns>.svc.cluster.local

    Resolve a Service FQDN from a temporary pod to tell CoreDNS problems from app DNS problems

  • kubectl events --for pod/<pod> -n <ns> --types=Warning

    Show only Warning events for one pod, in time order; the newer way instead of get events with filters

  • kubectl logs <pod> -n <ns> -c <name> --previous --timestamps --tail=200

    Show the last 200 lines of the previous container instance, with timestamps, to catch the stack trace before the restart

all 27 k8s-debug commands