Kubernetes Commands Cheat Sheet
A kubectl and Kubernetes commands cheat sheet for contexts, workloads, logs, debugging, scaling, rollout and safe resource changes.

This Kubernetes cheat sheet covers common kubectl tasks. Always confirm the active context and namespace before changing a cluster.
Context and discovery
kubectl config current-context | Show the active cluster context. |
kubectl config get-contexts | List available contexts. |
kubectl get namespaces | List namespaces. |
kubectl api-resources | List resource types supported by the server. |
kubectl version | Show client and server version information. |
Inspect workloads
kubectl get pods -n NAME | List pods in a namespace. |
kubectl get deploy,svc -n NAME | List deployments and services. |
kubectl describe pod POD -n NAME | Show status, events and configuration. |
kubectl logs POD -n NAME | Read container logs. |
kubectl logs POD --previous -n NAME | Read logs from the previous crashed container. |
Apply, scale and roll out
kubectl diff -f FILE | Preview declarative changes. |
kubectl apply -f FILE | Apply configuration. |
kubectl scale deploy/APP --replicas=3 | Change replica count. |
kubectl rollout status deploy/APP | Watch rollout progress. |
kubectl rollout undo deploy/APP | Roll back to the previous revision. |
Debug safely
Start with events, status and logs. Use kubectl exec only when the image contains the required tool, and prefer an approved debug-container workflow for minimal images. Avoid broad delete commands and never assume the default namespace or current context is correct.
Frequently asked questions
What is kubectl?
kubectl is the command-line tool that communicates with a Kubernetes cluster control plane through the Kubernetes API.
How do I check my current Kubernetes cluster?
Run kubectl config current-context, then inspect the context details before making changes.
Sources and further reading
Features, software and prices change. Confirm current details with these sources before making a decision.
Found something that needs updating? Send a correction with the page URL and a supporting source.