Created
November 23, 2021 04:43
-
-
Save nickpoulos/51072670c5f78b81183e2f662d3e7750 to your computer and use it in GitHub Desktop.
[K8s Delete Pods By Keyword] Delete any running K8s pods containing a keyword #k8s #bash
This file contains 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
# kubectl get pods | grep MyServiceName | while read -r line; do $line | awk '{print $1}' | kubectl delete pod $1; done | |
function delpods() { | |
local keyword=$1 | |
kubectl get pods | grep $keyword | while read -r line ; do | |
local containerName=$(awk -v var="$line" '{print $1}') | |
echo "Deleteing $containerName..." | |
kubectl delete pod $containerName | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment