kubectl get -o yaml: Usage, Options & Common CI Errors
Dump a live object exactly as the API server stores it.
kubectl get -o yaml prints the complete server representation of a resource - spec, status, and metadata. It is how you inspect what actually got applied and how you capture a baseline for debugging in CI.
What it does
kubectl get RESOURCE NAME -o yaml serialises the live object, including server-defaulted fields, status, and bookkeeping metadata (resourceVersion, uid, creationTimestamp, managedFields). It reflects reality after admission and defaulting, not just what you submitted.
Common usage
kubectl get deploy/web -o yaml
kubectl get deploy/web -o yaml > web.snapshot.yaml
kubectl get configmap app-cfg -o yaml | grep -A20 '^data:'
kubectl get pod my-pod -o yaml | yq '.status.conditions'Common errors in CI
The big gotcha is re-applying this output: a live -o yaml dump carries status, resourceVersion, uid, and managedFields, so kubectl apply -f it back errors or behaves oddly ("resourceVersion should not be set", metadata conflicts). To round-trip an object, strip the runtime fields first (or use kubectl get ... -o yaml --show-managed-fields=false plus a yq scrub). The dump can also be huge because of managedFields noise - pass --show-managed-fields=false to quiet it. Remember Secrets print base64-encoded data, not plaintext.