I'd like to do a kubectl get pods
and filter where the pod is in a status of ImagePullBackOff
.
I've tried kubectl get pods --field-selector=status.phase=waiting
and kubectl get pods --field-selector=status.phase=ImagePullBackOff
but that returns no results.
I've had a look at the JSON output with -o json
:
...
{
"image": "zzzzzzzzzzzzzzzz",
"imageID": "",
"lastState": {},
"name": "nginx",
"ready": false,
"restartCount": 0,
"state": {
"waiting": {
"message": "Back-off pulling image \"zzzzzzzzzzzzzzzz\"",
"reason": "ImagePullBackOff"
}
}
}
...
If I try target that value:
kubectl get pods --field-selector=state.waiting=ImagePullBackOff
Error from server (BadRequest): Unable to find "/v1, Resource=pods" that match label selector "", field selector "state.waiting=ImagePullBackOff": field label not supported: state.waiting
Using kubectl describe pods to check kube-system If the output from a specific pod is desired, run the command kubectl describe pod pod_name --namespace kube-system . The Status field should be "Running" - any other status will indicate issues with the environment.
So what exactly does ImagePullBackOff mean? The status ImagePullBackOff means that a Pod couldn't start, because Kubernetes couldn't pull a container image. The 'BackOff' part means that Kubernetes will keep trying to pull the image, with an increasing delay ('back-off').
To check if the status of your pods is healthy, the easiest way is to run the kubectl get pods command. After that, you can use kubectl describe and kubectl logs to obtain more detailed information.
Using json
output and piping through jq
:
kubectl get pod -o=json | jq '.items[]|select(any( .status.containerStatuses[]; .state.waiting.reason=="ImagePullBackOff"))|.metadata.name'
Last chunk |.metadata.name
means it'll list pod names instead of the entire structures.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With