Skip to main content

kubectl Cheat Sheet 2026 — Quick CLI Command Reference

kubectl Cheat Sheet 2026 — Quick Command Reference

kubectl Cheat Sheet is the complete quick-reference of kubectl commands grouped by function. Copy any command with one click and find what you need with Ctrl+F in under 3 seconds.

Pods & Containers

Action Command Useful flags
Update specified pod with the label `unhealthy` and the value `true`
kubectl label pods <name> unhealthy=true
Print the logs for a container in a pod or specified resource
kubectl logs <pod_name>
Run command in an existing pod
kubectl exec <pod_name> -- <ls />
List all pods
kubectl get pods
-n <namespace>
Describe a pod
kubectl describe pod <pod_name>
Delete a pod
kubectl delete pod <pod_name>
Execute interactive shell in pod
kubectl exec <pod_name>
-it -- /bin/sh
Copy files to/from pod
kubectl cp <src> <dest>
Forward ports to pod
kubectl port-forward pod/<pod_name> <local_port>:<remote_port>
-forward
Show pod resource usage
kubectl top pod <pod_name>
-n <namespace>

Deployments & ReplicaSets

Action Command Useful flags
Create deployment
kubectl create deployment <deployment-name> --image=<image>
--image
Update container image
kubectl set image deployment/<deployment-name> <container-name>=<new-image>
-image -name
Check rollout status
kubectl rollout status deployment/<deployment-name>
-name
Rollback deployment
kubectl rollout undo deployment/<deployment-name>
-name

Services & Networking

Action Command Useful flags
List all services with details
kubectl get services -o wide
-o wide
Forward local port to a service
kubectl port-forward service/<service-name> <local-port>:<service-port>
-forward -name -port

Namespaces & Contexts

Action Command Useful flags
Show current context
kubectl config current-context
-context
List all contexts
kubectl config get-contexts
-contexts
Set current context
kubectl config use-context <context>
-context
Set namespace in current context
kubectl config set-context <context> --namespace=<namespace>
--namespace -context
View current context config
kubectl config view --minify
--minify

ConfigMaps & Secrets

Action Command Useful flags
No commands detected for this group.

Persistent Volumes

Action Command Useful flags
List all PersistentVolumes
kubectl get pv
-o wide
Create a PersistentVolumeClaim from a YAML file
kubectl create -f <file.yaml>
-f

RBAC & Security

Action Command Useful flags
No commands detected for this group.

Diagnostics & Troubleshooting

Action Command Useful flags
List information about a resource with more details
kubectl get <pods|service|deployment|ingress|...> --output wide
--output
List all resources with different types
kubectl get all
Display resource (CPU/Memory/Storage) usage of nodes or pods
kubectl top <pods|nodes>
Print the address of the master and cluster services
kubectl cluster-info
Display an explanation of a specific field
kubectl explain <pods.spec.containers>
Describe a resource
kubectl describe <resource> <name>
-n <namespace>
Print pod logs
kubectl logs <pod-name>
-c <container-name>
List cluster events
kubectl get events
--sort-by='.lastTimestamp'
Forward local port to pod
kubectl port-forward <pod-name> <local-port>:<remote-port>
-forward -name -port
Show version info
kubectl version
--short
List API resources
kubectl api-resources
-o wide

⚠️ Dangerous / Destructive Commands

These commands are irreversible. Verify your environment (dev/staging vs prod) before running them.

Action Command Warning
⚠️ Delete
kubectl delete pod <pod_name>
Irreversible — verify the target before running

FAQ — Frequently Asked Questions

What is the difference between Pods & Containers and Deployments & ReplicaSets?

Each group in this kubectl cheat sheet covers a distinct area. Pods & Containers focuses on its specific scope, while Deployments & ReplicaSets and the remaining groups cover networking, storage, security and diagnostics respectively.

How do I check the installed kubectl version?

Run the version command (usually kubectl version or kubectl --version). The output shows the client and, when applicable, the server version.

Why does kubectl return ‘permission denied’?

A ‘permission denied’ error in kubectl usually means the current user lacks sufficient privileges or credentials are not configured. Check: (1) assigned IAM/RBAC roles, (2) an active authentication context via the corresponding login command.

How do I filter kubectl output by status or name?

Use flags such as --filter, --selector or --query depending on the tool. You can also pipe into grep or jq to process JSON:

kubectl list | grep RUNNING

What is the fastest way to debug a kubectl error?

Add the verbose flag (--verbose, -v or --debug) to the failing command. This reveals the underlying HTTP/API calls and the full error response body.

Official sources & references

Commands cross-checked against vendor documentation and high-authority repositories: