/plushcap/analysis/spacelift/kubectl-delete-pod

How to Delete Pods from a Kubernetes Node with Examples

What's this blog post about?

Deleting a pod from a Kubernetes (K8S) node is often required for troubleshooting or maintenance purposes. To delete all the pods from a particular node, first retrieve the names of the nodes and then the names of the pods using kubectl get commands. Use the kubectl drain command to evict the pods from the node and schedule them on another free node. The drain command will cordon the node to prevent new pods from being scheduled while you are preparing it for removal or maintenance. Once complete, verify that your pods are now running on a different node using kubectl get pods -o wide. To delete a single pod, use the kubectl delete pod command. Consider scaling the number of pods appropriately before deleting them and maintain application uptime by gracefully bringing pods up on another node before they are deleted.

Company
Spacelift

Date published
Nov. 9, 2022

Author(s)
Jack Roper

Word count
1208

Hacker News points
None found.

Language
English


By Matt Makai. 2021-2024.