Kubectl & Kubernetes Commands Cheat Sheet
Production Kubernetes CLI reference: pod management, rolling restarts, port-forwarding, ingress, secrets decoding, and node resource monitoring with 1-click copy.
Pods & Workloads (7 commands)
kubectl get pods -n <namespace>
Lists all pods running in the specified namespace with status, restarts, and age.
kubectl get pods -o wide
Displays pod list along with assigned Pod IP address and host worker node.
kubectl get pods -A
Retrieves all pods across every namespace in the Kubernetes cluster.
kubectl describe pod <pod-name>
Shows deep diagnostics, container states, resource limits, and recent cluster events.
kubectl logs -f <pod-name>
Streams live stdout/stderr logs from the primary container in the pod.
kubectl exec -it <pod-name> -- /bin/sh
Opens an interactive terminal session inside the running container.
kubectl delete pod <pod-name>
Terminates the specified pod. If managed by a Deployment, a new replica spawns automatically.
Deployments & Rollouts (5 commands)
kubectl get deployments
Lists available deployments, desired vs ready replicas, and update status.
kubectl scale deployment/<deployment-name> --replicas=5
Instantly increases or decreases the number of running pod replicas.
kubectl rollout restart deployment/<deployment-name>
Performs a rolling restart of all pods in the deployment without downtime.
kubectl rollout status deployment/<deployment-name>
Monitors the progress of a rolling deployment update until complete.
kubectl rollout undo deployment/<deployment-name>
Reverts the deployment back to the previous revision if a bug is detected.
Services & Networking (3 commands)
kubectl get svc
Shows all services, internal ClusterIPs, NodePorts, and LoadBalancer external IPs.
kubectl port-forward svc/<service-name> 8080:80
Forwards local machine traffic on port 8080 directly to port 80 of the Kubernetes service.
kubectl get ingress
Displays all configured HTTP/HTTPS Ingress rules, TLS hosts, and backend service routes.
ConfigMaps & Secrets (2 commands)
kubectl get configmaps
Shows non-sensitive configuration keys stored in the active namespace.
kubectl get secret <secret-name> -o jsonpath="{.data.<key>}" | base64 --decode
Extracts and decodes Base64-encoded secret keys directly in terminal.
Cluster & Nodes (3 commands)
kubectl top nodes
Shows current CPU cores and RAM consumption across all worker and control plane nodes.
kubectl top pods --sort-by=memory
Ranks pods by current RAM utilization to identify memory leak bottlenecks.
kubectl config use-context <context-name>
Switches kubectl target environment between local minikube, staging, and production.