Managing Kubernetes efficiently often comes down to knowing the right commands at the right time. Whether you’re debugging a pod, managing services, or deploying applications, this cheat sheet will become your go-to reference. Letโs break it down section by section with detailed explanations! ๐

๐ก Kubernetes Cluster Commands
๐ง These commands help you inspect your cluster and node status.
kubectl cluster-info
๐ Displays the control plane and DNS info.
kubectl get nodes -o wide
๐ Lists all nodes with additional details like internal IPs and OS info.
๐ณ Kubernetes Pod Commands
Pods are the smallest deployable units. Here’s how to interact with them:
kubectl get pods
kubectl get pods -o wide
kubectl get pods -l <label>=<value>
๐ View all pods, detailed info, or filtered by labels.
kubectl describe pod <name>
kubectl get pod <name>
kubectl logs <pod>
kubectl exec -it <pod> -- /bin/bash
๐ Inspect pod status, logs, or exec into a container for troubleshooting.
kubectl delete pod <name>
kubectl explain pod
๐๏ธ Delete or get detailed help about the pod spec.
๐ Deployment Commands
Deployments manage pod replicas and rollout strategies:
kubectl create deployment <name> --image=<image>
kubectl get deployments
kubectl describe deployment <name>
kubectl scale deployment <name> --replicas=<number>
kubectl rollout restart deployment/<name>
kubectl rollout status deployment/<name>
๐ก Scale, inspect, or restart a deployment easily.
For YAML generation:
kubectl create deployment <name> --image=<image> -o yaml
kubectl create deployment <name> --image=<image> --dry-run=client
kubectl create deployment <name> --image=<image> --dry-run=client -o yaml > name.yaml
๐ Use dry-run to test configs before applying them.
๐ Kubernetes Service Commands
Manage communication between components:
kubectl get services
kubectl describe service <name>
kubectl expose pod <name>
kubectl delete service <name>
kubectl port-forward <pod> <local-port>:<remote-port>
๐ Expose your apps or forward ports for local testing.
๐ ConfigMap & Secret Commands
Use these to externalize configs securely:
kubectl create configmap <name> --from-literal=<key>=<value>
kubectl create secret generic <name> --from-literal=<key>=<value>
kubectl get configmaps
kubectl get secrets
kubectl describe configmap <name>
๐ Securely store sensitive info and configs.
๐ท๏ธ Namespace Commands
Namespaces help organize resources:
kubectl get namespaces
kubectl create namespace <name>
kubectl delete namespace <name>
kubectl config set-context --current --namespace=<name>
๐ Switch between environments like dev, prod, etc.
๐ Resource Management Commands
Use these to apply, edit, or delete configurations:
kubectl apply -f <file>
kubectl edit <type> <name>
kubectl delete -f <file>
kubectl get <type>
kubectl describe <type> <name>
โ๏ธ Perfect for CI/CD workflows or manual ops.
๐ Statistics & Events
Diagnose and monitor your cluster:
kubectl top nodes
kubectl top pods
kubectl events
kubectl get events
๐ Great for spotting memory leaks, CPU spikes, or failed deployments.
๐ Kubernetes Permissions
kubectl get roles
๐ฎ Use this to view RBAC roles and access controls.