Donnerstag, 23. Januar 2020

List stucked pods in OpenShift or Kubernetes

As OpenShift or Kubernetes cluster administrator you probably know how to list all pods in your cluster using

oc get pods --all-namespaces

or

kubctl get pods --all-namespaces

This command will return a list of all pods which currently exist in your cluster. This list can be quite long and in case of troubleshooting way too verbose as most of the pods are in Running state and do not have any issues.

By using grep you can easily filter out pods with certain status and suffixes:

oc get pods --all-namespaces | grep -v -e "Running" -e "Completed" -e "-build" -e "-deploy"

In this example, you specify some regex patterns using the -e flag. The -v flag will then invert the matching and return all pods that potentially have a problem. Using an alias e.g. list-stuck-pods will give you a nice command to troubleshoot your pods.

Keine Kommentare:

Kommentar veröffentlichen

Hinweis: Nur ein Mitglied dieses Blogs kann Kommentare posten.