Created
          September 19, 2022 10:38 
        
      - 
      
 - 
        
Save bertrandmartel/42e8fbc83f7c7243e80d5ef3a0a1d9e7 to your computer and use it in GitHub Desktop.  
    Delete all stuck pods from a list of pod in a file
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| while IFS= read -r pod; do | |
| echo $pod | |
| namespace=$(kubectl get pods -o wide --all-namespaces -o custom-columns=":metadata.name, :metadata.namespace" | grep $pod | awk '{print $2}') | |
| if [ -n "$namespace" ]; then | |
| echo "deleting $pod on namespace $namespace" | |
| kubectl delete pod $pod --grace-period=0 --force -n $namespace | |
| else | |
| echo "$pod was not found." | |
| fi | |
| done < evicted.txt | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | pod-1 | |
| pod-2 | |
| pod-3 | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment