Skip to main content
intermediate Free with email

kubectl Commands Cheat Sheet: Troubleshoot Pods, Services and Nodes (Free PDF)

Reviewed 2026-11-01

Direct answer
The most useful kubectl commands are get, describe, logs, exec and rollout. Read the Events and previous logs before you restart anything, then fix the cause behind CrashLoopBackOff, exit code 137, ImagePullBackOff or a Service with no endpoints. This free 23-page PDF is a troubleshooting runbook for 16 common failures.

What Are the Most Useful kubectl Commands?

The most useful kubectl commands are get, describe, logs, exec and rollout, read together with the cluster’s Events, because they show what’s wrong before you change anything. This kubectl cheat sheet follows the free PDF, a 23-page troubleshooting runbook built on them, and adds the flags, version notes and Kubernetes documentation the PDF leaves out.

CommandWhat it showsUse it when
kubectl get pods -A -o wideStatus, restarts, node and IPFirst look at any incident
kubectl describe pod <pod> -n <ns>Conditions, Last State, EventsThe status isn’t Running
kubectl logs <pod> -n <ns> --previousOutput of the crashed containerCrashLoopBackOff
kubectl get events -n <ns> --sort-by=.lastTimestampScheduling, image and probe eventsPods are Pending or failing
kubectl top pods -A --sort-by=memoryLive CPU and memory useYou suspect an OOM kill
kubectl get endpointslices -n <ns>Ready backends behind a ServiceTraffic never arrives
kubectl exec -it <pod> -n <ns> -- shA shell inside the containerTesting ports, DNS or config
kubectl rollout undo deployment/<name>Rolls back one revisionA release went bad
kubectl auth can-i <verb> <resource>Allowed or deniedYou get a Forbidden error
kubectl drain <node> --ignore-daemonsetsEvicts Pods from a nodeNode maintenance

How Do You Check and Switch kubectl Context Safely?

Run kubectl config current-context before every change, because kubectl acts on whichever cluster the current context points at. The PDF opens its triage set with the same check.

kubectl config current-context
kubectl config get-contexts
kubectl config use-context <context>
kubectl config set-context --current --namespace=<ns>
kubectl version

kubectl version prints the client and server versions. Keep them close: the version skew policy supports kubectl one minor version older or newer than the API server. Every other everyday command is in the official kubectl quick reference.

Kubernetes Troubleshooting Workflow: kubectl logs, Describe and Events

Troubleshoot in this order: describe, events, logs, metrics, dependencies, then change history. A Pod status is a clue, not a root cause. Collect evidence before you restart anything, because Kubernetes keeps events for one hour by default (the kube-apiserver --event-ttl flag, default 1h0m0s) and deleting a Pod loses its previous logs.

kubectl describe pod <pod> -n <ns>
kubectl get events -n <ns> --sort-by=.lastTimestamp
kubectl logs <pod> -n <ns> --all-containers
kubectl logs <pod> -n <ns> --previous

Four kubectl logs flags do most of the work: --previous (the last crashed instance), -c <container> (one container in a multi-container Pod), -f (stream) and -l app=<name> (every Pod with that label). In kubectl describe, read Events at the bottom first, then Last State, Reason and Exit Code. The PDF’s runbook template makes you record eight things: symptom, scope, recent changes, evidence, root cause, fix, validation and prevention. For the “recent changes” row, our Git commands cheat sheet covers the history side.

Kubernetes troubleshooting workflow: kubectl describe pod, kubectl get events and kubectl logs --previous in three steps
Run kubectl describe, read the Events, then check kubectl logs –previous before you restart anything.

How to Fix CrashLoopBackOff in Kubernetes

CrashLoopBackOff means a container keeps exiting and the kubelet is waiting longer before each restart. It’s a symptom, not a cause. The Pod lifecycle docs give the delay as 10s, 20s, 40s and so on, capped at 5 minutes, reset after the container runs 10 minutes without problems.

The usual causes: the app exits on startup, a bad command or argument, a missing ConfigMap, Secret or variable, a dependency that’s down or rejects credentials, a liveness probe that kills a slow starter, or an OOM kill.

  1. Read kubectl logs <pod> --previous. Current logs may show only the newest attempt.
  2. Run kubectl describe pod <pod> and read Last State, Reason, Exit Code and Restart Count.
  3. Check the command, args, envFrom, ConfigMaps, Secrets and mounted files.
  4. Test the dependency from the same network context.
  5. Review probe thresholds and resource limits.

Exit code 1 alone isn’t a root cause. You’re done when the restart count stops rising and readiness passes.

CrashLoopBackOff and ImagePullBackOff are statuses; Last State and Events in kubectl describe show the cause
CrashLoopBackOff and ImagePullBackOff are retry delays, so read Last State and Events to find the cause.

Exit Code 137 and OOMKilled: What They Mean and How to Fix Them

Exit code 137 means the container was killed with SIGKILL. Shells report 128 plus the signal number, and SIGKILL is signal 9 (Bash manual). The usual cause is the out-of-memory (OOM) killer, and kubectl describe pod confirms it:

Last State:     Terminated
  Reason:       OOMKilled
  Exit Code:    137

That’s the output shown in the Kubernetes resource management docs. Memory limits are enforced by the kernel, which may terminate a container that exceeds its limit once it detects memory pressure. Exit 137 without OOMKilled can also mean a container ignored SIGTERM, because the kubelet sends SIGKILL once the grace period expires.

Measure before you change the limit: kubectl top pod <pod> -n <ns> --containers may fail if metrics-server is unavailable, so use Prometheus or CloudWatch then. Set the limit from the measured peak plus headroom. Raising it without checking node capacity can move the failure to the node. For Java, container memory isn’t the same as heap size.

How to Fix ImagePullBackOff and ErrImagePull

ErrImagePull is the failed pull, and ImagePullBackOff means Kubernetes is delaying retries. Read the Event message first: NotFound, unauthorized, timeout, TLS or rate limit. The Kubernetes debugging guide lists the first three checks: is the image name correct, was it pushed, and can it be pulled by hand.

kubectl describe pod <pod> -n <ns>
kubectl get pod <pod> -n <ns> -o jsonpath='{.spec.containers[*].image}'
kubectl get pod <pod> -n <ns> -o jsonpath='{.spec.imagePullSecrets[*].name}'

Then check the tag or digest, the pull Secret (how to pull from a private registry), and node egress, DNS, proxy and certificate trust. Try docker pull from your own machine first; our Docker commands cheat sheet lists it. An imagePullSecret doesn’t fix every private-image failure. On EKS, node IAM permissions for ECR and network reachability can fail too, so read Amazon EKS troubleshooting. Never paste credentials into chat or logs.

Why Is My Pod Stuck in Pending?

A Pending Pod hasn’t been scheduled, or a volume prerequisite is still unmet. The FailedScheduling event in kubectl describe pod names the constraint. Kubernetes lists exhausted CPU or memory and hostPort limits. The PDF adds node selectors, affinity, taints, an unbound PVC, quota, and an autoscaler that can’t add capacity.

kubectl describe pod <pod> -n <ns>
kubectl describe nodes
kubectl get pvc -n <ns>
kubectl get resourcequota,limitrange -n <ns>

Compare the Pod’s requests with each node’s allocatable resources, then check its tolerations against the node taints. Don’t lower requests just to force scheduling. Validate the app’s real needs and capacity headroom first.

Pod Running but Not Ready: Readiness, Liveness and Startup Probes

A Pod that’s Running but not Ready is usually failing its readiness probe, so Kubernetes keeps it out of Service endpoints. It doesn’t restart the container. A failing liveness probe does.

ProbeJob
ReadinessDecides whether the Pod receives Service traffic
LivenessRestarts a stuck container
StartupGives a slow starter time before liveness checks begin

The probe configuration guide covers all three. Test the exact health endpoint from inside the container:

kubectl exec <pod> -n <ns> -- sh -c 'wget -S -O- http://127.0.0.1:<port>/<path>'

If the image has no shell or wget, use kubectl debug (below). Set thresholds from measured start time, not guesswork.

Service Has No Endpoints: Check Selectors With kubectl get endpointslices

A Service with no endpoints usually has a selector that doesn’t match the Pod labels, or its Pods aren’t Ready. A Service can exist and resolve in DNS while having no usable backends, so check endpoints before you debug a load balancer.

kubectl get svc <svc> -n <ns> -o yaml
kubectl get pods -n <ns> --show-labels
kubectl get endpointslices -n <ns> -l kubernetes.io/service-name=<svc>

If the ENDPOINTS column says <none>, compare spec.selector with the labels, then check port, targetPort and the port the app really listens on. The Service debugging guide walks the same path. One update: the Endpoints API has been deprecated since Kubernetes v1.33 (see the Kubernetes announcement), so kubectl get endpoints prints a warning. The PDF lists both commands, and EndpointSlices are the one to learn.

Kubernetes Service with no endpoints: kubectl get svc, kubectl get pods --show-labels and kubectl get endpointslices
Read the Service selector, match it to the Pod labels, then list the EndpointSlices.

DNS, NetworkPolicy and Ingress: Where Does Traffic Stop?

Trace one request hop by hop: client, DNS, load balancer, Ingress, Service, EndpointSlice, Pod. Test each layer from a client Pod in the same namespace.

LayerFirst checkUsual cause
DNSkubectl exec <pod> -n <ns> -- nslookup <svc>.<ns>.svc.cluster.localCoreDNS unhealthy, or UDP/TCP 53 blocked
NetworkPolicykubectl get networkpolicy -ADefault-deny with no DNS egress rule
Ingresskubectl describe ingress <name> -n <ns>Wrong class, host, path or TLS Secret

CoreDNS Pods in kube-system carry the label k8s-app=kube-dns, so kubectl logs -n kube-system -l k8s-app=kube-dns reads them. DNS uses port 53 over UDP and TCP, as our common ports cheat sheet explains, and the network troubleshooting commands PDF covers nslookup and dig. If only one app fails, check its resolver library before blaming CoreDNS. NetworkPolicies are additive for allowed traffic, so read every policy that selects the source and destination Pod. Don’t delete all policies as a quick fix. Add the narrowest allow rule.

kubectl exec, port-forward and debug: Get Inside a Failing Pod

kubectl exec runs a command inside a container, and kubectl debug adds a throwaway container when the image has no shell. They’re the Kubernetes versions of docker exec and docker logs from the Docker cheat sheet.

kubectl exec -it <pod> -n <ns> -c <container> -- sh
kubectl port-forward svc/<svc> 8080:80 -n <ns>
kubectl debug -it <pod> -n <ns> --image=busybox:1.28 --target=<container>
kubectl debug node/<node> -it --image=busybox:1.28

--target shares the process namespace of the container you name, and ephemeral containers have been stable since Kubernetes v1.25 (Debug Running Pods). kubectl debug node/<node> mounts the node’s root filesystem at /host. For a network test the PDF runs kubectl run net-debug --rm -it --image=curlimages/curl -- sh. Use an approved image and delete temporary debug Pods afterwards.

Node NotReady, DiskPressure and kubectl drain

A NotReady node isn’t reporting a healthy status. The causes are a stopped kubelet, a failing container runtime, DiskPressure, MemoryPressure or PIDPressure, or a CNI or network fault. Start with kubectl describe node <node>: Conditions and Events come first. Then, with approved access, check the node itself:

systemctl status kubelet
journalctl -u kubelet --since '30 min ago'
df -h
df -i

df -i matters because a disk can run out of inodes before bytes. Our Linux commands cheat sheet covers systemctl and journalctl. Never delete files under the container runtime directories while it’s running.

To empty a node for maintenance, cordon it, drain it, then bring it back:

kubectl cordon <node>
kubectl drain <node> --ignore-daemonsets --delete-emptydir-data
kubectl uncordon <node>

Check PodDisruptionBudgets, replica capacity and stateful workloads first, as the safely drain a node guide explains. Don’t terminate a node as your first diagnostic step.

How to Restart a Pod With kubectl (and Roll Back a Bad Rollout)

There’s no kubectl restart pod command. Use kubectl rollout restart deployment/<name> for a rolling restart, or kubectl delete pod <pod> and let the controller recreate it. A bare Pod with no controller stays deleted.

kubectl rollout restart deployment/<name> -n <ns>
kubectl rollout status deployment/<name> -n <ns>
kubectl rollout history deployment/<name> -n <ns>
kubectl rollout undo deployment/<name> -n <ns> --to-revision=<n>

Force deletion (--force) doesn’t wait for confirmation that the Pod’s processes have stopped, so avoid it for Pods that share storage (kubectl delete reference). Rollback is a mitigation, not the root cause: confirm database schema compatibility and irreversible migrations first, then fix the cause and redeploy with immutable image tags or digests.

PVC Pending, HPA Not Scaling and RBAC Forbidden

SymptomFirst commandUsual cause
PVC Pendingkubectl describe pvc <claim> -n <ns>No matching StorageClass, wrong access mode, or a zone mismatch (EBS volumes are zone-bound)
HPA not scalingkubectl describe hpa <name> -n <ns>Metrics unavailable, or no CPU requests set. HPA adds Pods, not nodes
Forbiddenkubectl auth can-i get pods -n <ns> --as=<user>Missing Role verb or wrong binding. On EKS, IAM and RBAC are separate layers

Grant least privilege only. Don’t reach for cluster-admin to make an error disappear.

What’s Inside the Free Kubernetes Troubleshooting PDF?

The free PDF is 23 pages. It’s a runbook, not a tutorial, and it doesn’t teach Kubernetes fundamentals.

  • 16 failure runbooks. Each one has causes, evidence commands, a numbered sequence, a production caution and a recovery check.
  • A request-path table. Seven layers from client and DNS to the dependency.
  • A 7-step incident flow. Acknowledge, assess, stabilise, diagnose, recover, validate, learn.
  • An EKS checklist. CNI, ECR, load balancer, storage and observability.
  • Five practice incidents. Plus a 12-row symptom-to-first-evidence table and 10 common mistakes.

The PDF stops where practice starts. It has no cluster to break and no manifests to fix. You’ll need a cluster: our home lab guide covers a small k3s cluster, and Proxmox vs Docker lays out a three-VM Kubernetes practice lab. To build the cluster itself from code, see Terraform vs Ansible and the Terraform commands cheat sheet. Preparing for a DevOps interview? The DevOps interview questions PDF has a Kubernetes section and a five-step debug sequence.

Frequently asked questions

What is kubectl?
kubectl is the command-line tool for Kubernetes. It sends requests to the cluster's API server, so you can list, inspect, create, change and delete resources such as Pods, Services and Deployments from a terminal. Kubernetes is the platform, and kubectl is the tool you use to talk to it.
What are the most useful kubectl commands?
The most useful kubectl commands are kubectl get pods -A -o wide (status and restarts), kubectl describe pod (conditions and Events), kubectl logs --previous (the crashed container's output), kubectl exec -it -- sh (a shell inside), kubectl get events --sort-by=.lastTimestamp (cluster events) and kubectl rollout undo deployment/ (roll back). Read Events and logs before you restart anything.
How do I restart a pod with kubectl?
There's no kubectl restart pod command. Run kubectl rollout restart deployment/ for a rolling restart of a Deployment, or kubectl delete pod and let the controller create a replacement. A Pod with no controller isn't recreated after you delete it.
How do I force delete a pod in Kubernetes?
Run kubectl delete pod --force, or kubectl delete pod --now for a one-second grace period. Force deletion doesn't wait for confirmation that the Pod's processes have stopped, so avoid it for Pods that use shared storage or depend on a unique name. Try a normal delete first.
How do I find the reason for a pod restart?
Run kubectl describe pod and read Last State, Reason, Exit Code and Restart Count. Then read the previous container's output with kubectl logs --previous. A Last State of Terminated with Reason OOMKilled and Exit Code 137 means the container ran out of memory.
What does exit code 137 mean in Kubernetes?
Exit code 137 means the container was killed with SIGKILL, because shells report 128 plus the signal number and SIGKILL is signal 9. The usual cause is the out-of-memory killer, shown in kubectl describe pod as Reason OOMKilled. A container that ignores SIGTERM can also exit with 137 once the grace period ends and the kubelet sends SIGKILL.
What is CrashLoopBackOff and how do I fix it?
CrashLoopBackOff means a container keeps exiting and the kubelet waits longer before each restart: 10s, 20s, 40s and so on, up to 5 minutes. It's a symptom, not a cause. Read kubectl logs --previous, then Last State and Events in kubectl describe pod, and fix the cause: a bad command, missing config, a failing dependency, a liveness probe or an OOM kill.
What is the difference between ErrImagePull and ImagePullBackOff?
ErrImagePull is the failed attempt to pull an image. ImagePullBackOff means Kubernetes is delaying the next retry after failures. The Event message in kubectl describe pod gives the real cause, such as a wrong image name, a missing tag, an unauthorized registry or a network timeout.
Is the kubectl troubleshooting PDF free?
Yes. No credit card, just your email. The PDF is 23 pages and covers 16 common Kubernetes failures with the commands to run for each.

Questions about this PDF

No questions yet. Ask the first one.

Ask a question

Your email address won't be published. We review every question before it appears. How we handle your data. Required fields are marked

Reviewed by

CCDE/CCIE

How to cite this resource

SMEnode Labs (2026). kubectl Commands Cheat Sheet: Troubleshoot Pods, Services and Nodes (Free PDF). SMEnode Labs. https://smenode-labs.com/free-pdf/devops/kubectl-commands/

APA

SMEnode Labs. (2026). kubectl Commands Cheat Sheet: Troubleshoot Pods, Services and Nodes (Free PDF). SMEnode Labs. https://smenode-labs.com/free-pdf/devops/kubectl-commands/

BibTeX

@misc{smenodelabs2026,
  title = {kubectl Commands Cheat Sheet: Troubleshoot Pods, Services and Nodes (Free PDF)},
  author = {{SMEnode Labs}},
  year = {2026},
  url = {https://smenode-labs.com/free-pdf/devops/kubectl-commands/},
  note = {SMEnode Labs}
}