Get vs. Describe

Difficulty: Beginner

Question

What is the difference between `kubectl get` and `kubectl describe`, and when do you reach for each while debugging?

Answer

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.

What kubectl get gives you

  • A one-line summary per object: for Pods that is READY, STATUS, RESTARTS and AGE.
  • Flexible filtering: -n <ns>, -A for all namespaces, -l app=api for label selectors, --field-selector status.phase=Pending.
  • Output formats: -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.

What kubectl describe adds

describe is meant for humans, not scripts. For a Pod it shows:

  • Node, IP, labels, annotations, controlling owner (Controlled By: ReplicaSet/api-7d9f...).
  • Each container's image, state (Waiting, Running, Terminated), last state with exit code and reason (for example OOMKilled, exit code 137), and restart count.
  • Probes, mounts, resource requests and limits, QoS class, tolerations.
  • Conditions like PodScheduled and Ready.
  • Events from the scheduler and kubelet: 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.

A typical debugging flow

  1. kubectl get pods -n checkout shows api-... in CrashLoopBackOff with 7 restarts.
  2. kubectl describe pod api-... -n checkout shows last state Terminated, reason Error, exit code 1, and events with back-off.
  3. 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.

Quick comparison

kubectl getkubectl describe
AudienceHumans and scriptsHumans
OutputTable, YAML, JSON, jsonpathFormatted text report
Shows EventsNo (use kubectl get events or kubectl events)Yes
Many objects at onceYes, compactYes, but long
Best forStatus overview, exact field valuesRoot cause of a specific failure

Code examples

Everyday get and describe commands

# 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.

Key points

  • get = compact list or raw stored object; describe = human-readable report with related events.
  • Events are separate objects and are not included in get -o yaml.
  • Events expire (around one hour by default), so check them early.
  • Use get -o jsonpath or -o json with jq for scripting, never parse describe output.
  • describe shows container last state and exit codes, which explains CrashLoopBackOff and OOMKilled.

Common follow-up questions

  • How would you find out why a Pod is stuck in Pending?
  • What does exit code 137 mean in describe output?
  • How do you see logs from a container that already crashed?
  • How would you list all Pods running on a specific node?

Interview tips

  • Describe your actual debugging sequence: get, describe, logs --previous; it sounds like real experience.
  • Mention that Events are the key difference and that they expire.
  • Show you know get output formats like jsonpath and custom-columns for automation.

Concepts covered

kubectl get, kubectl describe, Events, Output Formats, Debugging

More Kubernetes & Orchestration questions