Skip to content

Instantly share code, notes, and snippets.

@greenygh0st
Last active March 24, 2022 00:59
Show Gist options
  • Save greenygh0st/579dbe591193a416ac8f484268235751 to your computer and use it in GitHub Desktop.
Save greenygh0st/579dbe591193a416ac8f484268235751 to your computer and use it in GitHub Desktop.
Removed bad and failed Kubernetes pods
# all
kubectl get pods --all-namespaces | grep -E 'ImagePullBackOff|ErrImagePull|Evicted|Terminating' | awk '{print $2 " --namespace=" $1}' | xargs kubectl delete pod --grace-period=0 --force
# not terminated
kubectl get pods --all-namespaces | grep -E 'ImagePullBackOff|ErrImagePull|Evicted' | awk '{print $2 " --namespace=" $1}' | xargs kubectl delete pod --grace-period=0 --force
# manual scaling adjustment
kubectl scale --replicas=0 deployment <deployment>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment