Difficulty: Beginner
What is the difference between `kubectl get` and `kubectl describe`, and when do you reach for each while debugging?
kubectl get lists one or more resources in a compact table (or as raw YAML/JSON with -o), which is ideal for a quick status check across many objects. kubectl describe prints a detailed, human-readable report for specific objects, including related information the object itself does not store, most importantly recent Events. Use get to spot what is broken and describe to find out why.
kubectl get gives youREADY, STATUS, RESTARTS and AGE.-n <ns>, -A for all namespaces, -l app=api for label selectors, --field-selector status.phase=Pending.-o wide (node and Pod IP), -o yaml/-o json (the full stored object), -o jsonpath=... and -o custom-columns=... for scripting.-w to watch changes live.Because get -o yaml returns exactly what is stored in etcd (spec plus status), it is the right tool for scripts, diffs and checking what a field is actually set to.
kubectl describe addsdescribe is meant for humans, not scripts. For a Pod it shows:
Controlled By: ReplicaSet/api-7d9f...).Waiting, Running, Terminated), last state with exit code and reason (for example OOMKilled, exit code 137), and restart count.PodScheduled and Ready.FailedScheduling, ErrImagePull, Back-off restarting failed container, FailedMount, Unhealthy (probe failures).Events are separate objects, so get -o yaml on the Pod will not show them. They are also short-lived (the API server keeps them for about an hour by default), so describe a failing Pod quickly or ship events to your logging stack.
kubectl get pods -n checkout shows api-... in CrashLoopBackOff with 7 restarts.kubectl describe pod api-... -n checkout shows last state Terminated, reason Error, exit code 1, and events with back-off.kubectl logs api-... --previous shows the stack trace from the crashed container.If the Pod were Pending, describe would show a FailedScheduling event such as 0/5 nodes are available: 5 Insufficient memory.
kubectl get | kubectl describe | |
|---|---|---|
| Audience | Humans and scripts | Humans |
| Output | Table, YAML, JSON, jsonpath | Formatted text report |
| Shows Events | No (use kubectl get events or kubectl events) | Yes |
| Many objects at once | Yes, compact | Yes, but long |
| Best for | Status overview, exact field values | Root cause of a specific failure |
# Overview with node placement
kubectl get pods -n checkout -o wide
# Only Pods that are not running yet
kubectl get pods -A --field-selector status.phase=Pending
# Exact image of every container in a Deployment
kubectl get deploy api -n checkout \
-o jsonpath='{.spec.template.spec.containers[*].image}'
# Full report with events for one Pod
kubectl describe pod api-7d9f8c6b5-x2k4q -n checkout
# Events for the namespace, newest last
kubectl get events -n checkout --sort-by=.lastTimestamp
get narrows down the problem quickly; describe and events explain what the scheduler or kubelet tried and why it failed.
kubectl get, kubectl describe, Events, Output Formats, Debugging