How to delete pods?

0155

To delete pods in Kubernetes, you can use the kubectl delete pod command followed by the name of the pod you want to delete. Here are a few examples:

  1. Delete a specific pod:

    kubectl delete pod <pod-name>
    
  2. Delete multiple pods:

    kubectl delete pod <pod-name-1> <pod-name-2>
    
  3. Delete all pods with a specific label:

    kubectl delete pods -l <label-key>=<label-value>
    
  4. Delete all pods in a namespace:

    kubectl delete pods --all -n <namespace>
    
  5. Force delete a pod (if it is stuck in a terminating state):

    kubectl delete pod <pod-name> --grace-period=0 --force
    

Make sure to replace <pod-name>, <label-key>, <label-value>, and <namespace> with the appropriate values for your use case.

0 Comments

no data
Be the first to share your comment!