kubectl get and describe
Inspect pods, nodes, deployments, and services with kubectl get and use describe output to understand object behavior and events.
Why get and describe Matter
Before you change anything in Kubernetes, you usually inspect what is already there. kubectl get gives you a quick list view, while kubectl describe gives you a deeper story.
Common kubectl get Commands
kubectl get pods
kubectl get nodes
kubectl get deployments
kubectl get services
kubectl get all
kubectl get all is convenient, but remember that it does not show literally every resource type in the cluster.
Useful Output Formats
kubectl get pods -o wide
kubectl get deployment web -o yaml
kubectl get service api -o json
When to Use Each
| Format | Best use |
|---|---|
| default table | Quick summaries |
-o wide | Extra networking and node details |
-o yaml | Full manifest-style object view |
-o json | Automation and tooling |
Reading Labels with Selectors
Labels help you group resources.
kubectl get pods -l app=web
kubectl get pods -l app=web,tier=frontend
Selectors are powerful because many Kubernetes resources use them to connect things together, especially Services and Deployments.
Using kubectl describe
kubectl describe pod my-pod
The output includes:
- metadata
- labels and annotations
- container images and ports
- conditions
- mounted volumes
- recent events
Why the Events Section Is Gold
The Events section often explains failures faster than anything else.
Common event clues include:
- image pull errors
- failed scheduling
- probe failures
- container restarts
kubectl describe pod my-pod
kubectl get pod my-pod -o yaml
Use describe when you want a human-friendly summary. Use -o yaml when you want the raw object structure.
A Practical Debugging Flow
kubectl get pods
kubectl get pods -o wide
kubectl describe pod my-pod
kubectl get pod my-pod -o yaml
Why This Skill Matters
Think of
kubectl getas looking at a building directory andkubectl describeas talking to the building manager. One gives quick listings. The other gives context.
These commands are the foundation of Kubernetes troubleshooting.
Best Command for Events
Which command is most useful when you want to read the event history for a pod?
Selector Use
What does `kubectl get pods -l app=web` do?