Kubernetes - List Abnormally Terminated Pods Across All Namespaces
Problem#
I want to get a list of all pods that have terminated abnormally along with their restart reason and count.
Solution#
Run the following command:
kubectl get pods --all-namespaces -o custom-columns='NAME:.metadata.name,REASON:.status.containerStatuses[0].lastState.terminated.reason,RESTARTS:.status.containerStatuses[0].restartCount' | grep -v '<none>\|Running\|Completed'