Skip to content

Instantly share code, notes, and snippets.

@swagfin
Created September 13, 2025 08:00
Show Gist options
  • Select an option

  • Save swagfin/871c817140fcb58af9fa091ffd174a44 to your computer and use it in GitHub Desktop.

Select an option

Save swagfin/871c817140fcb58af9fa091ffd174a44 to your computer and use it in GitHub Desktop.
Force Delete Stuck Pods in Kubernetes / MicroK8s

Force Delete Stuck Pods in Kubernetes / MicroK8s

Sometimes pods get stuck in the Terminating state due to node issues, kubelet problems, or blocking finalizers.
This guide shows how to force delete them both individually and across all namespaces.


🔹 Delete a Single Pod

microk8s kubectl delete pod <pod-name> -n <namespace> --grace-period=0 --force --wait=false

Example:

microk8s kubectl delete pod example-pod-57664595bd-whwcn -n example-pod-demo --grace-period=0 --force --wait=false

🔹 Delete All Terminating Pods in All Namespaces

microk8s kubectl get pods --all-namespaces   | grep Terminating   | awk '{print $2" -n "$1}'   | xargs -r -L1 microk8s kubectl delete pod --grace-period=0 --force --wait=false

🔹 Dry Run (List Only)

If you want to see which pods would be deleted without actually deleting them:

microk8s kubectl get pods --all-namespaces | grep Terminating

⚠️ Notes

  • --grace-period=0 tells Kubernetes not to wait before killing the pod.
  • --force bypasses the normal pod lifecycle checks.
  • --wait=false makes the command return immediately.

✅ With these commands, you can quickly clean up pods stuck in Terminating across your cluster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment