kubectl Cheatsheet - Command Reference
A kubectl command reference for app developers and cluster operators, covering resource queries, Pod diagnosis, replica scaling, and cluster context management. Unlike reading YAML directly, kubectl is the consistent window into cluster state and change control, letting you quickly localize frequent incidents such as CrashLoopBackOff, Pods stuck in Pending, and failed rollouts. By the end you can run the whole loop yourself: inspect status → check events → read logs → recover or roll back.
Get Resources 5
kubectl get pods -n prodkubectl get pods -o widekubectl get pods -Akubectl get svc,ingress -n prodkubectl get events --sort-by=.lastTimestampDescribe & Diagnose 5
kubectl describe pod <pod> -n prodkubectl logs <pod> -n prodkubectl logs <pod> --previouskubectl logs <pod> -c <container>kubectl exec -it <pod> -- shScale & Rollout 5
kubectl scale deploy/app --replicas=3kubectl rollout status deploy/appkubectl rollout undo deploy/appkubectl set image deploy/app c=app:1.1kubectl delete pod <pod>Context & Configuration 4
kubectl config get-contextskubectl config use-context <ctx>kubectl config set-context --current --namespace=prodkubectl top pod -n prodFAQ 5
Q: How do I list pods across all namespaces?Q: What is the difference between kubectl apply and kubectl create?Q: How do I view a pod log?Q: How do I shell into a pod container?Q: How do I check cluster node status?Tips
- Troubleshooting order: get for status → describe for events → logs for app errors, add --previous for CrashLoop.
- Run kubectl config get-contexts first to confirm the current cluster to avoid accidental operations on production.
- kubectl top errors usually mean metrics-server is not installed, not a command syntax issue.
Official References
Each command links to its official documentation below, so you can verify the latest usage and read deeper.
Maintained by LaoHand
Publicly updated on Jul 21, 2026, continuously proofread against official docs.
Contact Us
Wrong command or description? Send us corrections, business inquiries or product feedback by email.
Contact Us