Last active
September 14, 2023 17:41
-
-
Save xsqian/6b82f7731540f9bb2dfd6b05dcec08d0 to your computer and use it in GitHub Desktop.
How to delete all the pods that are in Completed status in a k8s
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 pod --field-selector=status.phase==Succeeded | |
kubectl delete pod --field-selector=status.phase==Succeeded | |
kubectl delete pod --field-selector=status.phase==Failed | |
kubectl delete pods $(kubectl get pod --all-namespaces -o jsonpath='{.items[?(@.status.containerStatuses[*].state.waiting.reason=="CrashLoopBackOff")].metadata.name}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment