Everything the API server stores has the same layout. Learn it once and you can read any object.
Five parts
text
learner@shallows:~$ kubectl get pod web -o yaml
apiVersion: v1 ← which API version
kind: Pod ← which kind of object
metadata: ← identity
name: web
namespace: shop
labels:
app: web
uid: 08a239bc-… ← set by the server
spec: ← what you asked for
containers:
- name: web
image: nginx:1.27
status: ← what actually happened
phase: Running
podIP: 10.42.0.9| Part | Who writes it | Holds |
|---|---|---|
apiVersion, kind | You | What this is |
metadata | You, plus the server | name, namespace, labels, and server fields like uid |
spec | You | The desired state |
status | The cluster | The observed state |
spec versus status
specwhat you want
controllers workuntil equal
statuswhat the cluster has
When spec and status agree, all is well. When they differ, something is in progress, or something is stuck. Comparing the two is most of troubleshooting.
Three ways to print an object
| Command | Shows |
|---|---|
kubectl get pod web | One row: the summary |
kubectl describe pod web | A report for people, with Events |
kubectl get pod web -o yaml | The whole object, exactly as stored |
-o json prints the same object as JSON. The YAML is the truth. When describe and your memory disagree, read the YAML.