How to Check Pod Events for Debugging in Kubernetes
Use the
kubectl describe pod [pod-name] command to see detailed events related to a pod. Alternatively, use kubectl get events --field-selector involvedObject.name=[pod-name] to filter events for that pod specifically.Syntax
The main commands to check pod events are:
kubectl describe pod [pod-name]: Shows detailed pod info including recent events.kubectl get events --field-selector involvedObject.name=[pod-name]: Lists only events related to the specified pod.
Replace [pod-name] with your actual pod's name.
bash
kubectl describe pod [pod-name] kubectl get events --field-selector involvedObject.name=[pod-name]
Example
This example shows how to check events for a pod named my-app-pod. It demonstrates using kubectl describe to see events and kubectl get events to filter events for that pod.
bash
kubectl describe pod my-app-pod kubectl get events --field-selector involvedObject.name=my-app-pod
Output
Name: my-app-pod
Namespace: default
...
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 2m default-scheduler Successfully assigned default/my-app-pod to node-1
Normal Pulled 1m kubelet Container image "nginx:latest" already present on machine
Normal Created 1m kubelet Created container my-app-container
Normal Started 1m kubelet Started container my-app-container
LAST SEEN TYPE REASON OBJECT MESSAGE
1m Normal Pulling Pod/my-app-pod Pulling image "nginx:latest"
30s Normal Pulled Pod/my-app-pod Successfully pulled image "nginx:latest"
30s Normal Created Pod/my-app-pod Created container my-app-container
30s Normal Started Pod/my-app-pod Started container my-app-container
Common Pitfalls
Common mistakes when checking pod events include:
- Not specifying the correct pod name, leading to no events shown.
- Using
kubectl get eventswithout filtering, which shows all cluster events and can be overwhelming. - Ignoring event timestamps, which help understand the sequence of issues.
Always double-check the pod name and use filtering to focus on relevant events.
bash
kubectl get events # Wrong: no filter, too many events kubectl get events --field-selector involvedObject.name=my-app-pod # Right: filtered events for specific pod
Quick Reference
| Command | Purpose |
|---|---|
| kubectl describe pod [pod-name] | Show detailed pod info including events |
| kubectl get events --field-selector involvedObject.name=[pod-name] | List events filtered by pod name |
| kubectl get pods | List all pods to find pod names |
| kubectl logs [pod-name] | Check pod logs for deeper debugging |
Key Takeaways
Use kubectl describe pod [pod-name] to see pod events and status details.
Filter events with kubectl get events --field-selector involvedObject.name=[pod-name] for focused debugging.
Always verify the pod name to avoid missing relevant events.
Check event timestamps to understand the order of occurrences.
Combine event checks with pod logs for full debugging context.