Get credentials before using kubectl
:
gcloud container clusters get-credentials my-cluster --project my-project --zone my-zone
Delete all pods (in all namespaces) that are in "Error" state:
kubectl get pods --show-all --all-namespaces | awk -e '$4 == "Error" {print $2 " --namespace=" $1}' | xargs kubectl delete pod