Kubernetes Troubleshooting Cheat Sheet

Debugging, inspection, RBAC checks, rollout failures, node health, and maintenance-oriented kubectl workflows.

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

Inspection and Deep Queries

Query cluster state efficiently.

Custom columns output

Render table output with selected fields.

bashANYoutputcustom-columns
bash
kubectl get pods -n payments -o custom-columns=NAME:.metadata.name,PHASE:.status.phase,NODE:.spec.nodeName,IP:.status.podIP
Notes

Render table output with selected fields.

Get JSON output

Dump a resource as JSON.

bashANYoutputjson
bash
kubectl get deployment web -n payments -o json
Notes

Dump a resource as JSON.

Get YAML output

Dump a resource as YAML.

bashANYoutputyaml
bash
kubectl get deployment web -n payments -o yaml
Notes

Dump a resource as YAML.

Sort resources

Sort list output by a JSONPath-like field.

bashANYgetsort
bash
kubectl get pods -n payments --sort-by=.status.startTime
Notes

Sort list output by a JSONPath-like field.

Field selector filter

Filter server-side using field selectors.

bashANYfield-selectorfilter
bash
kubectl get pods -A --field-selector=status.phase!=Running
Notes

Filter server-side using field selectors.

Label selector filter

Filter resources using labels.

bashANYselectorlabels
bash
kubectl get pods -n payments -l 'app=web,component=api'
Notes

Filter resources using labels.

Machine-friendly output

Suppress table headers for scripting.

bashANYscriptingoutput
bash
kubectl get pods -n payments --no-headers
Notes

Suppress table headers for scripting.

Get resource names only

Return resource identifiers only.

bashANYscriptingoutput
bash
kubectl get pods -n payments -o name
Notes

Return resource identifiers only.

Debugging Pods and Containers

Interactive and ephemeral debugging workflows.

Debug node with ephemeral pod

Launch a debugging pod on a node.

bashANYdebugnode
bash
kubectl debug node/worker-02 -it --image=busybox:1.36
Notes

Launch a debugging pod on a node.

Debug pod by copying it

Create a debug copy of a pod.

bashANYdebugpod
bash
kubectl debug web-abc123 -n payments --copy-to=web-debug --container=web -- sh
Notes

Create a debug copy of a pod.

Add ephemeral debug container

Inject an ephemeral debug container into a running pod.

bashANYdebugephemeral-container
bash
kubectl debug -it web-abc123 -n payments --image=nicolaka/netshoot --target=web
Notes

Inject an ephemeral debug container into a running pod.

Check RBAC permission

Ask the API server whether an action is allowed.

bashANYrbacauth
bash
kubectl auth can-i create deployments -n payments
Notes

Ask the API server whether an action is allowed.

Check permission as another identity

Test RBAC from another subject's perspective.

bashANYrbacauthimpersonation
bash
kubectl auth can-i get secrets -n payments --as=system:serviceaccount:payments:web
Notes

Test RBAC from another subject's perspective.

Show pod conditions

Print pod condition states.

bashANYpodconditionsjsonpath
bash
kubectl get pod web-abc123 -n payments -o jsonpath='{range .status.conditions[*]}{.type}{"="}{.status}{"
"}{end}'
Notes

Print pod condition states.

Describe failed pods by selector

Inspect all matching pods for failure clues.

bashANYdebugdescribe
bash
kubectl describe pods -n payments -l app=worker
Notes

Inspect all matching pods for failure clues.

Rollout and Scheduling Failures

Diagnose stuck updates and unschedulable pods.

List pending pods

Find pods waiting to schedule or start.

bashANYschedulingpending
bash
kubectl get pods -A --field-selector=status.phase=Pending
Notes

Find pods waiting to schedule or start.

Describe pending pod

Look for failed scheduling and image pull events.

bashANYschedulingdescribe
bash
kubectl describe pod pending-pod -n payments
Notes

Look for failed scheduling and image pull events.

Show node conditions

Check high-level node health indicators.

bashANYnodeconditions
bash
kubectl get nodes -o custom-columns=NAME:.metadata.name,READY:.status.conditions[?(@.type=="Ready")].status,MEMORYPRESSURE:.status.conditions[?(@.type=="MemoryPressure")].status,DISKPRESSURE:.status.conditions[?(@.type=="DiskPressure")].status
Notes

Check high-level node health indicators.

Pause deployment rollout

Temporarily pause a deployment rollout.

bashANYrolloutpause
bash
kubectl rollout pause deployment/web -n payments
Notes

Temporarily pause a deployment rollout.

Resume deployment rollout

Resume a paused deployment rollout.

bashANYrolloutresume
bash
kubectl rollout resume deployment/web -n payments
Notes

Resume a paused deployment rollout.

List PodDisruptionBudgets

Show PodDisruptionBudgets.

bashANYpdbget
bash
kubectl get pdb -A
Notes

Show PodDisruptionBudgets.

Describe PodDisruptionBudget

Inspect disruption constraints that may block eviction.

bashANYpdbdescribe
bash
kubectl describe pdb web -n payments
Notes

Inspect disruption constraints that may block eviction.

Cluster Maintenance and Cleanup

Bulk cleanup and namespace triage patterns.

Delete evicted pods

Pattern to find evicted pods for cleanup.

bashANYcleanupevicted
bash
kubectl get pods -A --field-selector=status.phase=Failed | grep Evicted | awk '{print $1, $2}'
Notes

Pattern to find evicted pods for cleanup.

Delete completed jobs

Clean up successful Jobs when appropriate.

bashANYcleanupjobs
bash
kubectl delete jobs -n ops --field-selector=status.successful=1
Notes

Clean up successful Jobs when appropriate.

Inspect finalizers

See whether finalizers are blocking deletion.

bashANYfinalizersnamespace
bash
kubectl get namespace stuck-ns -o jsonpath='{.spec.finalizers}'
Notes

See whether finalizers are blocking deletion.

Call API server health endpoint

Read API server health information.

bashANYapirawhealth
bash
kubectl get --raw='/healthz?verbose'
Notes

Read API server health information.

Call API server ready endpoint

Read API server readiness information.

bashANYapirawhealth
bash
kubectl get --raw='/readyz?verbose'
Notes

Read API server readiness information.

Get component statuses (legacy)

Legacy command seen on older clusters; modern clusters rely on health endpoints and metrics.

bashANYcomponentstatuseslegacy
bash
kubectl get componentstatuses
Notes

Legacy command seen on older clusters; modern clusters rely on health endpoints and metrics.