kubernetes kubectl · ·

Essential kubectl Commands Cheat Sheet

A quick reference for the most commonly used kubectl commands covering pods, deployments, services, and debugging.

Essential kubectl Commands Cheat Sheet

Pod Management

Command Description
kubectl get pods List all pods in current namespace
kubectl get pods -A List pods across all namespaces
kubectl describe pod <name> Show detailed pod information
kubectl delete pod <name> Delete a specific pod
kubectl logs <pod> View pod logs
kubectl logs <pod> -f Stream pod logs
kubectl exec -it <pod> -- sh Open shell in pod

Deployments

Command Description
kubectl get deployments List all deployments
kubectl scale deploy <name> --replicas=3 Scale a deployment
kubectl rollout status deploy/<name> Check rollout status
kubectl rollout undo deploy/<name> Rollback a deployment
kubectl set image deploy/<name> <container>=<image> Update container image

Services and Networking

Command Description
kubectl get svc List all services
kubectl get ingress List all ingress resources
kubectl port-forward svc/<name> 8080:80 Forward local port to service
kubectl get endpoints List service endpoints

Debugging

Command Description
kubectl get events --sort-by=.metadata.creationTimestamp View cluster events
kubectl top pods Show pod resource usage
kubectl top nodes Show node resource usage
kubectl logs <pod> --previous View logs from crashed container
kubectl describe node <name> Check node conditions

Context and Config

Command Description
kubectl config get-contexts List all contexts
kubectl config use-context <name> Switch context
kubectl config current-context Show current context
kubectl get ns List namespaces
kubectl config set-context --current --namespace=<ns> Set default namespace

Get the next article in your inbox

Practical DevOps tips, tutorials, and guides. No spam, unsubscribe anytime.