Skip to content

Instantly share code, notes, and snippets.

@georgeliaw
Last active February 6, 2019 22:47
Show Gist options
  • Save georgeliaw/a31ab8e2bd33cc9378fdaab8447e663c to your computer and use it in GitHub Desktop.
Save georgeliaw/a31ab8e2bd33cc9378fdaab8447e663c to your computer and use it in GitHub Desktop.
Delete failed kuberenetes pods
#!/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