🚀 Top 20 Most Useful kubectl
Commands for Everyday Kubernetes Workflows
Whether you're a developer, SRE, DevOps engineer, or just starting out with Kubernetes, mastering kubectl
is essential. Here’s a curated list of the top 20 kubectl
commands that are universally useful across teams and cloud platforms (EKS, GKE, AKS, etc.). These commands will save you time, reduce confusion, and help you debug faster.
🔟 Most Commonly Used kubectl
Commands
1. Get all pods across namespaces
kubectl get pods -A
Great for seeing what’s running cluster-wide and spotting stuck or crashing pods.
2. Describe a pod (deep debugging)
kubectl describe pod <pod-name> -n <namespace>
Reveals node assignment, events, taints, failed mounts, and more.
3. View logs from a pod
kubectl logs <pod-name> -n <namespace>
Use --previous
if the pod has crashed and restarted.
4. Exec into a running container
kubectl exec -it <pod-name> -n <namespace> -- /bin/sh
Great for real-time inspection, testing configs, or quick troubleshooting.
5. View recent events (cluster-wide)
kubectl get events -A --sort-by='.lastTimestamp'
Use this to see the latest cluster activity, scheduling failures, crashes, and warnings.
6. View resource usage per pod
kubectl top pods -A
Requires Metrics Server installed. Useful for performance monitoring.
7. Get all services across namespaces
kubectl get svc -A
Quickly see which services are exposed and their types (ClusterIP, LoadBalancer, etc).
8. Restart a deployment
kubectl rollout restart deployment <name> -n <namespace>
Triggers a rolling restart—useful after changing ConfigMaps, Secrets, or images.
9. Port forward to a service or pod
kubectl port-forward svc/<svc-name> 8080:80 -n <namespace>
Perfect for accessing internal services locally.
10. Get everything in a namespace
kubectl get all -n <namespace>
One-liner to view pods, deployments, services, etc., all at once.
🔟 More Essential kubectl
Commands
11. Check node info
kubectl get nodes -o wide
Displays node capacity, labels, roles, and IPs.
12. List namespaces with labels
kubectl get namespaces --show-labels
Helps with namespace-level Fargate profiles and label selectors.
13. Get custom resources (CRDs)
kubectl get crds
Essential when working with operators, controllers, or observability tooling.
14. Copy files into/from a pod
kubectl cp ./local-file.txt <pod-name>:/tmp/ -n <namespace>
Use this for backups, config injection, or pulling logs/artifacts out.
15. Apply a manifest
kubectl apply -f your-file.yaml
Declarative way to manage resources.
16. Delete a resource
kubectl delete deployment <name> -n <namespace>
Useful for clearing broken resources blocking Terraform or Helm.
17. Watch pod status live
kubectl get pods -n <namespace> -w
Great for seeing rollout or crash cycles in real time.
18. Label a resource
kubectl label pod <pod-name> env=staging -n <namespace>
Labels are powerful for selectors, policies, and organizing workloads.
19. Taint a node
kubectl taint nodes <node-name> key=value:NoSchedule
Advanced scheduling control—combine with pod tolerations.
20. Explain a Kubernetes resource
kubectl explain deployment.spec.template.spec.containers
Learn the structure of complex manifests right from the CLI.
✅ Wrap-up
Mastering these 20 kubectl
commands will level up your day-to-day efficiency in any Kubernetes environment—especially when using infrastructure as code with Terraform or Helm. Keep this cheat sheet close, and you'll debug faster and deploy smarter.
Feel free to bookmark or share! 🚀
Top comments (1)
Very useful. thank you.