CodeBlanks Logo Icon CodeBlanks

kubectl describe pod

Learn to inspect Pod issues with describe.

kubectl describe pod

If a pod never starts there are no logs either; the answer is in the Events section of the describe output. Common causes:

Events:
  Warning  Failed     kubelet  Failed to pull image "api:1.1": not found
  Warning  BackOff    kubelet  Back-off pulling image "api:1.1"          # ImagePullBackOff
  Warning  FailedScheduling  default-scheduler  0/3 nodes are available: 3 Insufficient memory.
  Warning  FailedMount  kubelet  configmap "api-ayar" not found
  Warning  Unhealthy  kubelet  Readiness probe failed: HTTP probe failed with statuscode: 503

Filtering events

Events are kept for about an hour. To see only warnings or a specific object, they are filtered:

kubectl get events --field-selector type=Warning
kubectl get events --field-selector involvedObject.name=api-xyz
kubectl describe pod api-xyz | sed -n '/Events/,$p'
kubectl get pod api-xyz -o jsonpath='{.status.containerStatuses[0].state}'

Practice Find the cause from the events

Write three commands: show the api-xyz pod in detail; list only the events of type Warning; list only the events of the api-xyz object with involvedObject.name.

Starter code

terminal
# buraya yaz

Sample solution

terminal
kubectl describe pod api-xyz
kubectl get events --field-selector type=Warning
kubectl get events --field-selector involvedObject.name=api-xyz

Expected output

Name:         api-xyz
Status:       Pending
Events:
  Warning  Failed  kubelet  Failed to pull image "api:1.1": not found
LAST SEEN   TYPE      REASON   OBJECT        MESSAGE
2m          Warning   Failed   pod/api-xyz   Failed to pull image "api:1.1": not found

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What are the most common causes of ImagePullBackOff?

  • Insufficient memory
  • An application bug
  • A wrong port
  • A wrong image name/tag or missing imagePullSecrets for a private registry Correct answer

Explanation: The "not found" vs "unauthorized" distinction in the event shows the cause.

2 Show only the warning events.

Question
kubectl get events --field-selector type=____
Answer
kubectl get events --field-selector type=Warning

Explanation: Event types are Normal and Warning.

3 Match the events.

Term Meaning
Failed to pull image Image couldn't be pulled
Insufficient memory No room on the nodes
configmap not found Missing config
Readiness probe failed Not ready

All lessons in Intermediate