December 1, 2026

Kubernetes troubleshooting is where theory meets reality. You have read the docs, you understand the architecture, but when a pod is stuck in CrashLoopBackOff at 3 AM, you need a systematic approach, not a textbook.

This guide distills years of production Kubernetes debugging into a repeatable methodology. Every technique here has been used to resolve real incidents.

The Debugging Mindset

Before diving into commands, internalize this framework:

  1. Start wide, narrow fast – Check cluster health first, then namespace, then pod
  2. Follow the dependency chain – Pod to Node to Network to Storage to Control plane
  3. Correlate timestamps – Events, logs, and metrics must align
  4. Assume nothing – Verify each layer independently

Layer 1: Cluster Health Check (30 seconds)

# Are nodes ready?
kubectl get nodes -o wide
# Look for: NotReady, SchedulingDisabled, memory/disk pressure

# Control plane health
kubectl get componentstatuses
# Or for managed clusters:
kubectl get --raw=/readyz?verbose

# Cluster events (last hour)
kubectl get events --all-namespaces --sort-by=.metadata.creationTimestamp | tail -50

Red flags: Multiple NotReady nodes, control plane component failures, repeated OOMKilled events across nodes.

Layer 2: Namespace-Level Triage (1 minute)

# What is broken in this namespace?
kubectl get all -n 
kubectl get events -n  --sort-by=.metadata.creationTimestamp

# Resource quotas exhausted?
kubectl describe quota -n 

# Limit ranges constraining pods?
kubectl describe limitrange -n 

Layer 3: Pod Deep Dive (The Meat)

Pod Phase Analysis

# Get full pod status
kubectl describe pod  -n 

# Key fields to check:
# - Phase: Pending, Running, Succeeded, Failed, Unknown
# - Conditions: PodScheduled, ContainersReady, Initialized, Ready
# - Events: Bottom of output - read chronologically

Common Pod States and Fixes

State Likely Cause First Command
Pending No schedulable node kubectl describe pod > Events
ContainerCreating Image pull / CNI / CSI Check events, then node logs
CrashLoopBackOff App crash, config error kubectl logs --previous
ImagePullBackOff Wrong image, no credentials Check image name, imagePullSecrets
OOMKilled Memory limit too low Check limits, kubectl top pod
Evicted Node pressure kubectl describe node
Completed Job finished (expected) Verify exit code

The CrashLoopBackOff Protocol

# 1. Current logs (may be empty if crashing fast)
kubectl logs  -n  -c 

# 2. Previous container logs (THE MOST IMPORTANT)
kubectl logs  -n  -c  --previous

# 3. If no logs at all: check container command
kubectl get pod  -n  -o jsonpath="{.spec.containers[*].command}"

# 4. Check init containers
kubectl logs  -n  -c  --previous

Pro tip: --previous is the single most underused flag. It shows why the container crashed before the current restart.

Debugging Running Pods (Exec Access)

# Interactive shell (if shell exists)
kubectl exec -it  -n  -c  -- /bin/sh

# Distroless/scratch images: use ephemeral container (K8s 1.25+)
kubectl debug -it  -n  --image=busybox --target=

# Copy files out for analysis
kubectl cp /:/path/to/file ./local-file -c 

# Port forward for local debugging
kubectl port-forward  -n  8080:8080

Layer 4: Service & Networking Debugging

Service Not Working? Check the Chain

# 1. Service exists and has endpoints?
kubectl get svc -n 
kubectl get endpoints -n 

# 2. Endpoints empty? Selector mismatch
kubectl describe svc  -n 
# Check: spec.selector matches pod labels exactly

# 3. DNS resolution
kubectl exec -it  -n  -- nslookup ..svc.cluster.local

# 4. Service IP reachable from pod?
kubectl exec -it  -n  -- curl -v :

# 5. kube-proxy rules on node
kubectl debug node/ -it --image=busybox -- chroot /host iptables -L -n -t nat | grep 

CNI-Specific Debugging

Calico:

# Check BGP peers
calicoctl get bgppeer

# Check IP pool
calicoctl get ippool

# Policy enforcement
calicoctl get networkpolicy -n 

Cilium:

# Hubble CLI for flow visibility
hubble observe -n  --protocol http

# Check Cilium endpoints
cilium endpoint list

# BPF map inspection
cilium bpf lb list

Flannel:

# Check flannel subnet on node
cat /run/flannel/subnet.env

# VXLAN interface
ip -d link show flannel.1

NetworkPolicy Debugging

# Is traffic being dropped?
kubectl exec -it  -n  -- timeout 5 curl -v 

# Check NetworkPolicy
kubectl get networkpolicy -n 
kubectl describe networkpolicy  -n 

# Simulate policy evaluation (Cilium)
cilium policy verify --dst  --dport 80 --protocol tcp

Layer 5: Storage Issues

# PVC stuck in Pending?
kubectl describe pvc  -n 
# Check: StorageClass exists, provisioner healthy, capacity available

# Volume mount failures
kubectl describe pod  -n 
# Look for: VolumeManager.ReconstructFailed, MountVolume.SetUp failed

# CSI driver logs
kubectl logs -n kube-system -l app=csi-driver -c csi-driver --tail=100

Layer 6: Control Plane (When Nothing Else Makes Sense)

# API server latency
kubectl get --raw=/metrics | grep apiserver_request_duration_seconds

# etcd health (managed clusters: check cloud console)
# Self-hosted:
etcdctl endpoint health --cluster

# Controller manager logs
kubectl logs -n kube-system -l component=kube-controller-manager --tail=100

# Scheduler logs
kubectl logs -n kube-system -l component=kube-scheduler --tail=100

The kubectl Debug Toolbox (K8s 1.25+)

# Ephemeral container for ANY pod (even distroless)
kubectl debug -it  -n  --image=ghcr.io/cilium/hubble-ui-client --target=

# Copy pod with debug containers
kubectl debug  -n  --copy-to=debug-pod --image=busybox

# Node-level debug shell
kubectl debug node/ -it --image=busybox -- chroot /host

# Profile endpoints
kubectl debug pod/ -n  --image=busybox --profile=sysadmin

Essential Aliases for Daily Use

Add to your ~/.bashrc or ~/.zshrc:

alias k="kubectl"
alias kg="kubectl get"
alias kgp="kubectl get pods"
alias kgs="kubectl get svc"
alias kd="kubectl describe"
alias kl="kubectl logs"
alias klp="kubectl logs --previous"
alias kex="kubectl exec -it"
alias kpf="kubectl port-forward"
alias kctx="kubectl config use-context"
alias kns="kubectl config set-context --current --namespace"

# Custom functions
kdp() { kubectl describe pod "$1" -n "${2:-default}"; }
klf() { kubectl logs -f "$1" -n "${2:-default}" -c "${3}"; }
kep() { kubectl get endpoints "$1" -n "${2:-default}" -o wide; }

Incident Response Checklist

When paged for a Kubernetes incident:

  • kubectl get nodes – Any NotReady?
  • kubectl get pods -A --field-selector=status.phase!=Running – What is broken?
  • kubectl get events -A --sort-by=.metadata.creationTimestamp | tail -30 – Recent events
  • Check cloud provider status page
  • Check recent deployments: kubectl rollout history -n
  • Can you rollback? kubectl rollout undo -n
  • Document timeline in incident channel
  • Post-incident: run kubectl describe on affected pods, save output

Tools Worth Installing

Tool Purpose Install
kubectx/kubens Fast context/namespace switching brew install kubectx
k9s Terminal UI for K8s brew install k9s
stern Multi-pod log tailing brew install stern
kubectl-tree Resource hierarchy kubectl krew install tree
kubectl-debug Ephemeral containers (pre-1.25) kubectl krew install debug
popeye Cluster sanitizer brew install popeye

Summary: The 5-Minute Triage

# 1. Cluster healthy?
kubectl get nodes

# 2. What pods are unhappy?
kubectl get pods -A --field-selector=status.phase!=Running

# 3. Pick one, describe it
kubectl describe pod  -n 

# 4. Check previous logs
kubectl logs  -n  --previous

# 5. Check events
kubectl get events -n  --sort-by=.metadata.creationTimestamp

# 6. If networking: check endpoints, DNS, NetworkPolicy
kubectl get endpoints -n 
kubectl exec -it  -n  -- nslookup 

# 7. If storage: check PVC, StorageClass, CSI logs
kubectl describe pvc -n 

This methodology has resolved everything from “why is my pod pending” to “why is cross-zone traffic dropping 5% of requests.” The commands are standard; the discipline to follow the chain without jumping to conclusions is what separates guessing from debugging.

Leave a Reply

Your email address will not be published. Required fields are marked *