kubectl Cheatsheet

Search kubectl commands by verb and copy them in one click.

Searchable kubectl cheatsheet covering get, describe, apply, delete, exec, logs, rollout, scale and config commands — each with the real flags, a plain-English explanation and a copy button.

How do I follow logs from a crashing pod?

Use kubectl logs -f POD to stream live logs. If the container already crashed and restarted, add --previous to read the logs from the prior instance, which usually contains the crash cause.

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 example kubectl get pods -w while 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 k to kubectl and use kgp for kubectl get pods.
  • Always validate before applying to production with kubectl diff -f manifest.yaml and kubectl apply -f manifest.yaml --dry-run=server.
  • Placeholders like POD, NAME, NS and deploy/NAME in the copied commands should be replaced with your real resource names.