Last active
February 6, 2019 22:47
-
-
Save georgeliaw/a31ab8e2bd33cc9378fdaab8447e663c to your computer and use it in GitHub Desktop.
Delete failed kuberenetes pods
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 | |
| NAMESPACE=default | |
| CONTEXT=k8s.example.localhost.com | |
| kubectl get pods --field-selector=status.phase=Failed --namespace=$NAMESPACE --context=$CONTEXT | awk {'if (FNR > 1) print $1'} | xargs kubectl delete pod --namespace=$NAMESPACE --context=$CONTEXT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment