The Ultimate Kubernetes Cheat Sheet: Essential kubectl Commands for 2026
Key Takeaways
- kubectl is the core tool for managing Kubernetes clusters, enabling you to inspect, deploy, troubleshoot, and scale workloads from the command line. Knowing when and how to use key flags like
-n,-o, and--dry-runis essential. - Use a consistent workflow for debugging: get → describe → logs. This structured approach helps surface issues faster and reduces troubleshooting time.
- Favor declarative over imperative commands by using YAML manifests with
kubectl apply. This promotes version control, repeatability, and cleaner operations.
Kubernetes (K8s) has become the de-facto standard for orchestrating containerized applications but managing it can be overwhelming without the right tools. At the center of every Kubernetes workflow is kubectl, the command-line utility that lets you interact with clusters, deploy applications, inspect resources, and troubleshoot issues.
This cheat sheet is your quick-reference guide to the most useful kubectl commands, organized by category and paired with examples. Whether you’re just getting started or looking for advanced tricks, this resource will help you master Kubernetes faster.
Kubernetes at a glance: key concepts
Before diving into commands, it helps to understand the core K8s building blocks you’ll be working with:
- Pods are the smallest deployable units in Kubernetes.
- Deployments manage sets of pods and apply declarative updates.
- Services expose your applications internally or externally.
- Namespaces provide logical isolation of workloads and resources by creating virtual clusters within a larger physical cluster.
- Nodes are worker machines where workloads run.
- Clusters refer to collections of nodes.
- Contexts define environments (like prod, or staging) and let you easily switch between them.
- YAML is the primary format for defining Kubernetes objects.
With these concepts in mind, let’s move through kubectl commands from basic inspection to advanced operations.
Before you dive in
Make sure kubectl is installed and your kubeconfig files are configured for your cluster. If you’re not sure, follow the official installation guide.
Next, learn how to set up “Vanilla” Kubernetes — that’s the nickname for Kubernetes outside a managed service like those provided by a cloud provider).
Inspecting and understanding your cluster
Use these commands to quickly list and describe what's running in your cluster.
kubectl get podskubectl get podskubectl get pods -nkubectl get pods -n kube-systemkubectl get serviceskubectl get serviceskubectl get deploymentskubectl get deploymentskubectl get nodeskubectl get nodeskubectl get allkubectl get allkubectl describe podkubectl describe pod nginx-podkubectl describe servicekubectl describe service my-servicekubectl describe deploymentkubectl describe deployment webkubectl describe nodekubectl describe node worker-1kubectl get pods -o widekubectl get pods -o wideDeploying and managing applications
These commands let you create, update, and scale workloads in Kubernetes.
kubectl apply -fkubectl apply -f app.yamlkubectl create -fkubectl create -f app.yamlkubectl delete -fkubectl delete -f app.yamlkubectl delete podkubectl delete pod nginx-podkubectl delete servicekubectl delete service my-servicekubectl delete deploymentkubectl delete deployment webkubectl scale deployment --replicas=Nkubectl scale deployment web --replicas=5kubectl rollout status deployment/kubectl rollout status deployment/webkubectl rollout undo deployment/kubectl rollout undo deployment/webDebugging and troubleshooting
When troubleshooting pod issues, begin by reviewing events to catch any error messages or warnings early — events firing that show errors is often a good place to start investigating.
After that, follow a systematic workflow: get → describe → logs. This approach helps identify problems quickly before deeper inspection.
When pods fail to start or restart repeatedly, you'll often see states like ImagePullBackOff (image can't be pulled) or CrashLoopBackOff (container keeps crashing). Use kubectl describe pod <pod> to determine the pod state and kubectl logs <pod> to diagnose the root cause.
Logs & exec
kubectl logskubectl logs nginx-podkubectl logs -fkubectl logs -f api-podkubectl logs -ckubectl logs mypod -c sidecarkubectl logs --previouskubectl logs mypod --previouskubectl exec -it -- /bin/bashkubectl exec -it mypod -- /bin/bashkubectl exec -it --kubectl exec -it mypod -- curl localhost:8080kubectl cp :/remote/file ./localkubectl cp mypod:/var/log/app.log ./app.logkubectl port-forward pod/ :kubectl port-forward pod/mypod 8080:80Resource usage
kubectl top nodeskubectl top nodeskubectl top podskubectl top podsNetworking checks
For deeper debugging, you can run common tools like ping, curl, or nslookup inside a pod using kubectl exec. This helps verify connectivity, DNS resolution, and service reachability directly from within the cluster.
kubectl get endpointskubectl get endpoints web-svckubectl get ingresskubectl get ingresskubectl describe ingresskubectl describe ingress app-ingresskubectl get networkpolicieskubectl get networkpoliciesAdvanced operations: storage, configs & rollouts
Once you're comfortable with the basics, these commands give you more fine-grained control.
Storage
kubectl get pvkubectl get pvkubectl get pvckubectl get pvckubectl get sckubectl get sckubectl describe pvkubectl describe pv my-pvkubectl describe pvckubectl describe pvc my-claimkubectl describe sckubectl describe sc standardConfigs & secrets
kubectl get configmapkubectl get configmap app-configkubectl describe configmapkubectl describe configmap app-configkubectl get secretkubectl get secret db-secretkubectl describe secretkubectl describe secret db-secretRollouts
kubectl rollout history deployment/kubectl rollout history deployment/webkubectl rollout pause deployment/kubectl rollout pause deployment/webkubectl rollout resume deployment/kubectl rollout resume deployment/webkubectl set image deployment/ =kubectl set image deployment/web app=nginx:1.19kubectl edit /kubectl edit deployment/webPower user commands: going beyond the basics
Once you've mastered the essentials, these commands will give you deeper visibility and finer-grained control of your cluster.
More granular inspection
kubectl get all -Akubectl get all -Akubectl get events -A --sort-by='.lastTimestamp'kubectl get events -A --sort-by='.lastTimestamp'kubectl get pods --show-labelskubectl get pods --show-labelskubectl get -o yamlkubectl get pod nginx -o yamlkubectl get -o jsonkubectl get svc my-service -o jsonAdvanced logs & exec
kubectl logs --since=kubectl logs --since=1h nginx-podkubectl logs --tail=kubectl logs --tail=50 api-podkubectl exec -it --kubectl exec -it mypod -- curl localhost:8080Cluster & context management
kubectl cluster-infokubectl cluster-infokubectl config current-contextkubectl config current-contextkubectl config get-contextskubectl config get-contextskubectl config use-contextkubectl config use-context stagingkubectl versionkubectl versionkubectl explainkubectl explain podBeyond kubectl: bonus K8s ecosystem tools
- Package manager for Kubernetes:
helm - Terminal UI for clusters:
k9s - Quickly switch between clusters (contexts):
kubectx - Quickly switch between namespaces:
kubens - Create local Kubernetes clusters for dev/test:
minikube / kind
Best practices for stable Kubernetes operations
Kubernetes is powerful, but it can quickly get messy without guardrails. These practices help ensure efficiency, reliability, and stability in your clusters.
Efficiency tips and productivity hacks
- Autocompletion:
source <(kubectl completion bash) - Aliases:
alias k=kubectl - Dry-run flag: Test changes without applying:
kubectl apply -f app.yaml --dry-run=client - Namespaces: Always check the namespace (
-n flag) - Labels & selectors: Filter resources with
-l key=value - Declarative over imperative: Prefer YAML manifests (
apply -f)
Operational best practices
Define resource requests and limits to prevent noisy-neighbor issues. Misconfigured or missing resource constraints are among the top causes of Kubernetes errors. You can check resource requests and limits for your pods using this command:
kubectl get pods -n <namespace> -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[*].resources.requests.cpu}{"\t"}{.spec.containers[*].resources.limits.cpu}{""}{end}'
This lists each pod's name along with its CPU requests and limits, helping identify pods without proper resource constraints. For example:
my-app-pod-1 500m 1
my-app-pod-2 250m 500m
Setting appropriate CPU and memory requests ensures pods get guaranteed resources, while limits prevent excessive consumption, avoiding cluster resource contention and performance issues.
Additional best practices include:
- Use liveness and readiness probes for app health.
- Version-control all manifests in Git.
- Monitor events (
kubectl get events -A --sort-by='.lastTimestamp') to detect problems early.
Conclusion
Perfecting kubectl isn't about memorizing every command — it's about knowing the right sequence for the right situation. With this cheat sheet, you'll be equipped to inspect, deploy, troubleshoot, and scale Kubernetes workloads with confidence.
Splunk supports Kubernetes workloads
Splunk Observability Cloud is built for monitoring Kubernetes workloads, with powerful features like Kubernetes Navigator designed specifically for the K8s environment. Use it to get an AI-assisted overview of your applications and infrastructure in one simple place.
FAQs: kubectl and common Kubernetes commands
kubectl create makes new resources, while kubectl apply creates or updates resources declaratively based on a YAML/JSON file. Specifically, kubectl create is imperative and cannot update existing resources.kubectl describe pod, inspect logs with kubectl logs <pod>, and review events with kubectl get events.kubectl cp <pod>:/path/to/file ./local-name to copy files between your local system and a container.kubectl config get-contexts to see all contexts, then kubectl config use-context <name>to switch.Related Articles

How to Use LLMs for Log File Analysis: Examples, Workflows, and Best Practices

Beyond Deepfakes: Why Digital Provenance is Critical Now

The Best IT/Tech Conferences & Events of 2026

The Best Artificial Intelligence Conferences & Events of 2026

The Best Blockchain & Crypto Conferences in 2026

Log Analytics: How To Turn Log Data into Actionable Insights

The Best Security Conferences & Events 2026

Top Ransomware Attack Types in 2026 and How to Defend
