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-run is 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.

Pro tip: Already comfortable with the basics? Jump ahead to the Power User Commands.

Kubernetes at a glance: key concepts

Before diving into commands, it helps to understand the core K8s building blocks you’ll be working with:

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.

Command
What it does
Example
kubectl get pods
List all pods in current namespace
kubectl get pods
kubectl get pods -n
List pods in a specific namespace
kubectl get pods -n kube-system
kubectl get services
List all services
kubectl get services
kubectl get deployments
List all Deployments
kubectl get deployments
kubectl get nodes
List all nodes in the cluster
kubectl get nodes
kubectl get all
List all resources in namespace
kubectl get all
kubectl describe pod
Detailed info about a pod
kubectl describe pod nginx-pod
kubectl describe service
Detailed info about a service
kubectl describe service my-service
kubectl describe deployment
Detailed info about a Deployment
kubectl describe deployment web
kubectl describe node
Detailed info about a node
kubectl describe node worker-1
kubectl get pods -o wide
Show pods with additional info: IPs, node assignments, pod status, etc.
kubectl get pods -o wide

Deploying and managing applications

These commands let you create, update, and scale workloads in Kubernetes.

Command
What it does
Example
kubectl apply -f
Create/update resources from YAML
kubectl apply -f app.yaml
kubectl create -f
Create resources
kubectl create -f app.yaml
kubectl delete -f
Delete resources
kubectl delete -f app.yaml
kubectl delete pod
Delete a specific pod
kubectl delete pod nginx-pod
kubectl delete service
Delete a specific service
kubectl delete service my-service
kubectl delete deployment
Delete a specific Deployment
kubectl delete deployment web
kubectl scale deployment --replicas=N
Scale replicas
kubectl scale deployment web --replicas=5
kubectl rollout status deployment/
Check rollout status of a Deployment
kubectl rollout status deployment/web
kubectl rollout undo deployment/
Roll back a Deployment
kubectl rollout undo deployment/web

Debugging 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

Command
What it does
Example
kubectl logs
Show pod logs
kubectl logs nginx-pod
kubectl logs -f
Stream pod logs
kubectl logs -f api-pod
kubectl logs -c
Show logs from a specific container
kubectl logs mypod -c sidecar
kubectl logs --previous
Show logs from a previous container instance
kubectl logs mypod --previous
kubectl exec -it -- /bin/bash
Open shell inside container
kubectl exec -it mypod -- /bin/bash
kubectl exec -it --
Run a command inside a container
kubectl exec -it mypod -- curl localhost:8080
kubectl cp :/remote/file ./local
Copy files to/from pod
(From a pod): kubectl cp mypod:/var/log/app.log ./app.log
kubectl port-forward pod/ :
Forward a local port to a pod (The example makes port 80 on mypod available on port 8080 of the local machine.)
kubectl port-forward pod/mypod 8080:80

Resource usage

Command
What it does
Example
kubectl top nodes
Show node CPU/memory
kubectl top nodes
kubectl top pods
Show pod CPU/memory
kubectl top pods

Networking 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.

Command
What it does
Example
kubectl get endpoints
Show service endpoints
kubectl get endpoints web-svc
kubectl get ingress
List ingress rules
kubectl get ingress
kubectl describe ingress
Detailed ingress info
kubectl describe ingress app-ingress
kubectl get networkpolicies
List network policies
kubectl get networkpolicies

Advanced operations: storage, configs & rollouts

Once you're comfortable with the basics, these commands give you more fine-grained control.

Storage

Command
What it does
Example
kubectl get pv
List Persistent Volumes
kubectl get pv
kubectl get pvc
List Persistent Volume Claims
kubectl get pvc
kubectl get sc
List Storage Classes
kubectl get sc
kubectl describe pv
Detailed info about a PV
kubectl describe pv my-pv
kubectl describe pvc
Detailed info about a PVC
kubectl describe pvc my-claim
kubectl describe sc
Describe a storage class
kubectl describe sc standard

Configs & secrets

Command
What it does
Example
kubectl get configmap
Get a ConfigMap
kubectl get configmap app-config
kubectl describe configmap
Show details of a ConfigMap
kubectl describe configmap app-config
kubectl get secret
Get a Secret
kubectl get secret db-secret
kubectl describe secret
Show secret details
kubectl describe secret db-secret

Rollouts

Command
What it does
Example
kubectl rollout history deployment/
View rollout history
kubectl rollout history deployment/web
kubectl rollout pause deployment/
Pause rollout
kubectl rollout pause deployment/web
kubectl rollout resume deployment/
Resume rollout
kubectl rollout resume deployment/web
kubectl set image deployment/ =
Update container image
kubectl set image deployment/web app=nginx:1.19
kubectl edit /
Edit a live resource definition
kubectl edit deployment/web

Power 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

Command
What it does
Example
kubectl get all -A
List all resources across all namespaces
kubectl get all -A
kubectl get events -A --sort-by='.lastTimestamp'
View recent cluster-wide events
kubectl get events -A --sort-by='.lastTimestamp'
kubectl get pods --show-labels
Show pods with their labels
kubectl get pods --show-labels
kubectl get -o yaml
Output resource as YAML
kubectl get pod nginx -o yaml
kubectl get -o json
Output resource as JSON
kubectl get svc my-service -o json

Advanced logs & exec

Command
What it does
Example
kubectl logs --since=
Show logs since a given time
kubectl logs --since=1h nginx-pod
kubectl logs --tail=
Show last N log lines
kubectl logs --tail=50 api-pod
kubectl exec -it --
Run a specific command inside a pod
kubectl exec -it mypod -- curl localhost:8080

Cluster & context management

Command
What it does
Example
kubectl cluster-info
Show cluster master & services info
kubectl cluster-info
kubectl config current-context
Show current context
kubectl config current-context
kubectl config get-contexts
List all contexts
kubectl config get-contexts
kubectl config use-context
Switch to another context
kubectl config use-context staging
kubectl version
Show client & server version
kubectl version
kubectl explain
Show resource definition docs
kubectl explain pod

Beyond kubectl: bonus K8s ecosystem tools

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

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:

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

What is kubectl used for?
kubectl is the CLI tool for interacting with Kubernetes clusters, allowing you to deploy apps, inspect resources, and manage workloads.
What’s the difference between kubectl apply and create?
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.
How do I troubleshoot a pod stuck in CrashLoopBackOff?
Common causes of this state are a bad container deployment or insufficient resource allocation. Check the pod with kubectl describe pod, inspect logs with kubectl logs <pod>, and review events with kubectl get events.
Can I copy files into or out of a pod?
Yes. Use kubectl cp <pod>:/path/to/file ./local-name to copy files between your local system and a container.
How do I switch Kubernetes clusters with kubectl?
Run 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
Learn
7 Minute Read

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

Learn how to use LLMs for log file analysis, from parsing unstructured logs to detecting anomalies, summarizing incidents, and accelerating root cause analysis.
Beyond Deepfakes: Why Digital Provenance is Critical Now
Learn
5 Minute Read

Beyond Deepfakes: Why Digital Provenance is Critical Now

Combat AI misinformation with digital provenance. Learn how this essential concept tracks digital asset lifecycles, ensuring content authenticity.
The Best IT/Tech Conferences & Events of 2026
Learn
5 Minute Read

The Best IT/Tech Conferences & Events of 2026

Discover the top IT and tech conferences of 2026! Network, learn about the latest trends, and connect with industry leaders at must-attend events worldwide.
The Best Artificial Intelligence Conferences & Events of 2026
Learn
4 Minute Read

The Best Artificial Intelligence Conferences & Events of 2026

Discover the top AI and machine learning conferences of 2026, featuring global events, expert speakers, and networking opportunities to advance your AI knowledge and career.
The Best Blockchain & Crypto Conferences in 2026
Learn
5 Minute Read

The Best Blockchain & Crypto Conferences in 2026

Explore the top blockchain and crypto conferences of 2026 for insights, networking, and the latest trends in Web3, DeFi, NFTs, and digital assets worldwide.
Log Analytics: How To Turn Log Data into Actionable Insights
Learn
11 Minute Read

Log Analytics: How To Turn Log Data into Actionable Insights

Breaking news: Log data can provide a ton of value, if you know how to do it right. Read on to get everything you need to know to maximize value from logs.
The Best Security Conferences & Events 2026
Learn
6 Minute Read

The Best Security Conferences & Events 2026

Discover the top security conferences and events for 2026 to network, learn the latest trends, and stay ahead in cybersecurity — virtual and in-person options included.
Top Ransomware Attack Types in 2026 and How to Defend
Learn
9 Minute Read

Top Ransomware Attack Types in 2026 and How to Defend

Learn about ransomware and its various attack types. Take a look at ransomware examples and statistics and learn how you can stop attacks.
How to Build an AI First Organization: Strategy, Culture, and Governance
Learn
6 Minute Read

How to Build an AI First Organization: Strategy, Culture, and Governance

Adopting an AI First approach transforms organizations by embedding intelligence into strategy, operations, and culture for lasting innovation and agility.