Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Oats87/9bc9bf133e792e2ea08a97ae2ba9d460 to your computer and use it in GitHub Desktop.
Save Oats87/9bc9bf133e792e2ea08a97ae2ba9d460 to your computer and use it in GitHub Desktop.
#!/bin/bash
export KUBECONFIG=$(pwd)/kube_config_cluster.yml
IFS=$'\n'; for i in $(kubectl get secrets --all-namespaces | grep "service-account-token"); do ns=$(echo $i | awk '{print $1}'); sec=$(echo $i | awk '{print $2}'); kubectl patch secret -n $ns $sec -p '{"metadata":{"finalizers": []}}' --type=merge && kubectl delete secret $sec -n $ns --wait=false; done
IFS=$'\n'; for i in $(kubectl get pods --all-namespaces | grep -v "NAME"); do ns=$(echo $i | awk '{print $1}'); pod=$(echo $i | awk '{print $2}'); kubectl delete pod $pod -n $ns --wait=false; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment