HomeCheat SheetsKubernetes (kubectl) Commands Cheat Sheet
100% Client-Side β€’ 0 B Data Leaves Browser
devops

Kubernetes (kubectl) Commands Cheat Sheet

Comprehensive kubectl commands cheat sheet for managing Kubernetes clusters, pods, deployments, services, ingress, and configmaps.

Cluster & Nodes

Display cluster endpoint addresses and core serviceskubectl cluster-info
List all worker and master nodes with OS, kernel, and internal IPskubectl get nodes -o wide
Inspect CPU/memory allocation, conditions, and taints on a nodekubectl describe node <node-name>
View current CPU and memory consumption per nodekubectl top nodes

Pods & Debugging

List all running pods across all namespaceskubectl get pods -A
Watch status updates for pods matching label app=backend in real-timekubectl get pods -l app=backend -w
Stream live stdout/stderr log output from specific pod containerkubectl logs -f <pod-name> -c <container>
Open interactive bash/sh shell session inside running containerkubectl exec -it <pod-name> -- /bin/sh
Forward local port 8080 directly to port 80 on remote podkubectl port-forward <pod-name> 8080:80

Deployments & Scaling

Perform rolling restart of all pods in a deployment with zero downtimekubectl rollout restart deployment/<name>
Scale deployment replica count up or down instantlykubectl scale deployment/<name> --replicas=5
Check the real-time rollout status of a new image releasekubectl rollout status deployment/<name>
Rollback deployment to immediately preceding revisionkubectl rollout undo deployment/<name>

Frequently Asked Questions

β€’ How do I quickly switch namespaces in kubectl?

You can run `kubectl config set-context --current --namespace=<namespace-name>` to change your default active namespace without typing -n on every command.