Skip to content

Instantly share code, notes, and snippets.

@superseb
Last active November 12, 2020 19:27
Show Gist options
  • Save superseb/0f654d4e8945195e08fd1a2a061e0762 to your computer and use it in GitHub Desktop.
Save superseb/0f654d4e8945195e08fd1a2a061e0762 to your computer and use it in GitHub Desktop.
Delete evicted pods kubectl
#!/bin/bash
kubectl get pods --all-namespaces -o go-template='{{range .items}}{{if eq .status.phase "Failed"}}{{if eq .status.reason "Evicted"}}{{.metadata.name}}{{" "}}{{.metadata.namespace}}{{"\n"}}{{end}}{{end}}{{end}}' | while read epod namespace; do kubectl -n $namespace delete pod $epod; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment