Kubernetes Debugging Cheat Sheet

Core kubectl troubleshooting commands for pods, deployments, services, events, logs, exec sessions, and ephemeral debugging.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Cluster Triage

Check kubectl and server version

Show client and server version details.

bashANYkubectlversiontriage
bash
kubectl version --short

Show cluster endpoints

Display the control plane and addon URLs known to kubectl.

bashANYclustertriage
bash
kubectl cluster-info

List nodes

Quickly see whether nodes are Ready.

bashANYnodestriage
bash
kubectl get nodes

List nodes with details

Show node IPs, versions, and roles.

bashANYnodestriage
bash
kubectl get nodes -o wide

List all major resources

Quick cluster-wide snapshot across namespaces.

bashANYtriageresources
bash
kubectl get all -A

List resource types

See which resource kinds the API server exposes.

bashANYapitriage
bash
kubectl api-resources

Dump cluster diagnostic info

Collect broad cluster state for troubleshooting.

bashANYclusterdiagnostics
bash
kubectl cluster-info dump

Pods and Workloads

List pods across all namespaces

Find failing pods anywhere in the cluster.

bashANYpodstriage
bash
kubectl get pods -A

List pods with node and IP

Show placement and pod IP information.

bashANYpodsplacement
bash
kubectl get pods -A -o wide

Get full pod YAML

Inspect raw spec and status fields.

bashANYpodsyaml
bash
kubectl get pod <pod> -n <namespace> -o yaml

Describe a pod

Read conditions, events, mounts, image pulls, and restarts.

bashANYpodsdescribe
bash
kubectl describe pod <pod> -n <namespace>

List deployments

Find workloads with rollout or availability issues.

bashANYdeploymentsrollout
bash
kubectl get deployments -A

Describe a deployment

Inspect replica counts, rollout conditions, and selector details.

bashANYdeploymentdescribe
bash
kubectl describe deployment <name> -n <namespace>

Check rollout status

Wait for or inspect deployment rollout progress.

bashANYdeploymentrollout
bash
kubectl rollout status deployment/<name> -n <namespace>

List ReplicaSets

See which ReplicaSet a rollout created and whether scaling succeeded.

bashANYreplicasetrollout
bash
kubectl get rs -n <namespace>

List StatefulSets

Inspect ordered pod creation and update status.

bashANYstatefulsetworkloads
bash
kubectl get statefulsets -A

Describe a Job

Inspect failures, completions, and backoff behavior.

bashANYjobsbatch
bash
kubectl describe job <name> -n <namespace>

Events and Conditions

List events in a namespace

See recent warnings and scheduling errors.

bashANYeventswarnings
bash
kubectl get events -n <namespace>

Sort events by time

Show oldest to newest event timestamps for a namespace.

bashANYeventstimeline
bash
kubectl get events -n <namespace> --sort-by=.metadata.creationTimestamp

Sort cluster-wide events by time

Helpful for cluster-wide incident triage.

bashANYeventscluster
bash
kubectl get events -A --sort-by=.metadata.creationTimestamp

Wait for pod readiness

Use readiness conditions to gate troubleshooting steps or scripts.

bashANYwaitready
bash
kubectl wait --for=condition=Ready pod/<pod> -n <namespace> --timeout=60s

List pod phase and reason

Compact custom columns view for triage.

bashANYpodsconditions
bash
kubectl get pods -n <namespace> -o custom-columns=NAME:.metadata.name,PHASE:.status.phase,REASON:.status.containerStatuses[0].state.waiting.reason

Logs, Exec, and Ephemeral Debugging

Read pod logs

Print logs from a single-container pod.

bashANYlogspods
bash
kubectl logs <pod> -n <namespace>

Read logs from a specific container

Required for multi-container pods.

bashANYlogscontainers
bash
kubectl logs <pod> -n <namespace> -c <container>

Stream logs

Follow logs live while reproducing an issue.

bashANYlogsstreaming
bash
kubectl logs -f <pod> -n <namespace>

Read previous container logs

Useful after restarts or CrashLoopBackOff.

bashANYlogscrashloop
bash
kubectl logs <pod> -n <namespace> -p

Read logs for pods matching a label

Aggregate logs from a workload set.

bashANYlogslabels
bash
kubectl logs -n <namespace> -l app=<label> --all-containers=true --prefix

Open a shell in a running container

Run commands inside a pod for live inspection.

bashANYexecshell
bash
kubectl exec -it <pod> -n <namespace> -- /bin/sh

Inspect environment variables

Quickly validate environment and injected secrets names.

bashANYexecenv
bash
kubectl exec <pod> -n <namespace> -- env

Copy a file from a pod

Pull logs or generated files out of a running container.

bashANYcopyfiles
bash
kubectl cp <namespace>/<pod>:/path/in/pod ./local-file

Attach an ephemeral debug container

Launch a temporary debugging container in an existing pod.

bashANYdebugephemeral-containers
bash
kubectl debug -it <pod> -n <namespace> --image=busybox:1.36 --target=<container>

Create a copy of a pod for debugging

Duplicate a pod and add a debug container or different command.

bashANYdebugcopy-pod
bash
kubectl debug <pod> -n <namespace> --copy-to=<pod>-debug --container=debugger --image=busybox:1.36 -it

Port-forward to a pod

Reach a pod locally without exposing a Service.

bashANYport-forwardpods
bash
kubectl port-forward pod/<pod> -n <namespace> 8080:80

JSONPath and Useful One-Liners

List pods with restart counts

Spot frequently restarting containers quickly.

bashANYjsonpathrestarts
bash
kubectl get pods -A -o custom-columns=NS:.metadata.namespace,POD:.metadata.name,RESTARTS:.status.containerStatuses[*].restartCount

Show which node each pod runs on

Correlate pod failures with node placement.

bashANYjsonpathplacement
bash
kubectl get pods -A -o custom-columns=NS:.metadata.namespace,POD:.metadata.name,NODE:.spec.nodeName

List images used by all pods

Find image tags currently running in the cluster.

bashANYjsonpathimages
bash
kubectl get pods -A -o jsonpath='{..image}' | tr -s '[[:space:]]' '
' | sort | uniq -c

Show not-ready pods

Filter pods whose Ready condition is false or missing.

bashANYpodsnot-ready
bash
kubectl get pods -A --field-selector=status.phase!=Running

Show pod CPU and memory usage

Requires metrics-server; useful for resource-based incidents.

bashANYmetricsresources
bash
kubectl top pods -A

Show node CPU and memory usage

Identify hot or memory-constrained nodes.

bashANYmetricsnodes
bash
kubectl top nodes

Recommended next

No recommendations yet.