A fast kubectl reference
kubectl is the command-line client for the Kubernetes API server. This cheatsheet groups the commands you reach for daily — inspecting, applying, debugging and rolling out workloads — with the real flags and a one-line explanation. Filter by verb, search for a keyword, and copy the command straight to your clipboard.
How it works
Every kubectl command is a structured call to the cluster’s REST API. The first word after kubectl is the verb (get, describe, apply, delete, logs, exec, rollout, scale, config), followed by a resource type and name, then flags that shape the request and output.
Output flags are especially useful: -o wide adds columns, -o yaml dumps the full live object, and -o jsonpath='{...}' extracts a single field. Selectors with -l key=value operate on every matching object at once. The cheatsheet’s group filter maps directly to these verbs so you can scan one category at a time.
Tips and examples
- Watch resources change in real time with
-w, for examplekubectl get pods -wwhile a rollout proceeds. - Debug failures by combining describe and events:
kubectl describe pod my-pod
kubectl get events --sort-by=.lastTimestamp
- Set short aliases for speed: many engineers alias
ktokubectland usekgpforkubectl get pods. - Always validate before applying to production with
kubectl diff -f manifest.yamlandkubectl apply -f manifest.yaml --dry-run=server. - Placeholders like
POD,NAME,NSanddeploy/NAMEin the copied commands should be replaced with your real resource names.