Kubernetes kubectl Cheat Sheet — Cluster Operations & Debugging
Essential kubectl commands for inspecting pods, streaming logs, debugging deployments, port-forwarding services, and applying manifests.
Cluster & Resource Inspection
kubectl get pods -A -o wide
List all running pods across every namespace with node IPs and status
kubectl describe pod <pod-name>
Inspect events, resource limits, readiness probes, and failure reasons
kubectl logs -f <pod-name> -c <container>
Stream live container stdout/stderr log output in real time
kubectl logs --previous <pod-name>
Inspect logs from a crashed or OOMKilled container instance
Interactive Debugging & Networking
kubectl exec -it <pod-name> -- /bin/sh
Open an interactive shell session inside a live running container
kubectl port-forward svc/<service> 8080:80
Forward local port 8080 directly to remote cluster service port 80
kubectl rollout restart deployment/<name>
Trigger a rolling update restart of all pods in a deployment
kubectl top nodes / kubectl top pods
Display live CPU and memory utilization metrics