Batch 01 · Aarambh — AWS + Agentic AI starts 28 June 2026Batch 01 · Aarambh — AWS + Agentic AI starts 28 June 2026Batch 01 · Aarambh — AWS + Agentic AI starts 28 June 2026Batch 01 · Aarambh — AWS + Agentic AI starts 28 June 2026Batch 01 · Aarambh — AWS + Agentic AI starts 28 June 2026Batch 01 · Aarambh — AWS + Agentic AI starts 28 June 2026Batch 01 · Aarambh — AWS + Agentic AI starts 28 June 2026Batch 01 · Aarambh — AWS + Agentic AI starts 28 June 2026
All cheatsheets
Kubernetes · Cheatsheet

kubectl + k9s Cheatsheet

Imperative & declarative kubectl, port-forwards, debugging tricks, and the k9s shortcuts that save your wrists.

Updated 2026-05-21 8 min

Context + namespaces

kubectl config get-contextsList configured clusters/contexts
kubectl config use-context prod-eksSwitch context
kubectl config set-context --current --namespace=appDefault namespace for current context
kubectx prod-eks / kubens appFaster context/ns switching (krew plugins)
kubectl get nsList all namespaces

Inspect resources

kubectl get all -n appEverything in namespace
kubectl get pods -o widePods + node + IP
kubectl get po -l app=api --watchWatch pods by label
kubectl describe pod <name>Events + container status
kubectl get events --sort-by=.lastTimestampCluster events, freshest last
kubectl explain deployment.spec.strategyInline API docs
kubectl api-resources | grep ingressFind resource short-names + group

Logs & exec

kubectl logs -f deploy/apiFollow deployment logs
kubectl logs -f pod -c sidecar --since=10mSidecar logs, last 10 min
kubectl logs --previous podLogs from crashed previous container
kubectl exec -it pod -- shShell into a pod
kubectl debug node/ip-x -it --image=alpinePrivileged debug pod on a node (1.25+)
kubectl cp pod:/var/log/x.log ./x.logCopy file out of pod

Port-forward & proxy

kubectl port-forward svc/api 8080:80Hit service on localhost:8080
kubectl port-forward pod 5005:5005Forward a single pod port
kubectl proxy --port 8001API server proxy on localhost

Imperative create / scale / rollout

kubectl create deploy api --image=nginxQuick deployment
kubectl scale deploy api --replicas=5Scale
kubectl set image deploy/api api=nginx:1.27Roll out a new image
kubectl rollout status deploy/apiWatch the rollout
kubectl rollout undo deploy/apiUndo last rollout
kubectl rollout history deploy/apiPast revisions

Declarative apply

kubectl apply -f manifests/Apply directory
kubectl apply -k overlays/prod/Apply Kustomize overlay
kubectl diff -f manifest.yamlServer-side diff before apply
kubectl delete -f manifest.yamlDelete what was created
kubectl get pod -o yaml > pod.yamlExport YAML for editing

Debugging cheats

kubectl run tmp --rm -it --image=nicolaka/netshoot -- shThrowaway pod with curl/dig/nslookup/tcpdump
kubectl top pods / nodesLive CPU + mem (needs metrics-server)
kubectl auth can-i delete pod -n appCheck RBAC for current user
kubectl get pod x -o jsonpath='{.status.containerStatuses[*].state}'Drill into pod state

k9s shortcuts (terminal UI)

:pod / :deploy / :svcJump to resource view
/textFilter by substring
dDescribe selected
lLogs (Shift+L = previous)
sShell into pod
yView YAML
eEdit live
Ctrl+dDelete (with confirm)
:xray podResource dependency graph

Want the full hands-on training behind this?

Cloudadhar batches walk you through every command in a real production setup — with labs, code reviews, and 1:1 doubt sessions.