Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Kubernetes Incident Diagnosis Method

By updated

Improve this page

Logo Kubernetes

When a Kubernetes incident hits, always start with the same reflex: qualify the level of the problem (cluster, node, pod or network), then work your way down methodically. This guide gives you a systematic approach in 4 levels, with the kubectl commands that fit each situation. You will be able to locate the cause of an incident in a few minutes instead of searching at random.

What you will learn

  • Apply a 4-level triage method: cluster → node → pod → network
  • Use the 4 basic diagnostic commands: get, describe, logs, events
  • Use kubectl debug with ephemeral containers to inspect a running pod
  • Diagnose Service problems: DNS, EndpointSlices, kube-proxy

Prerequisites

  • A working Kubernetes cluster on 1.37, the version the course teaches
  • kubectl configured and connected to the cluster
  • Read access to nodes, pods, events, logs and services
  • You have followed the guide Observe the health of a cluster
  • Basic knowledge of Services and of DNS in Kubernetes

Why use a repeatable method?

Under pressure, the natural reflex is to go straight to the logs of the suspect Pod. That is often a waste of time: if the problem comes from the node (full disk, kubelet down) or from the network (misconfigured Service, broken DNS), those logs will show nothing useful.

A structured method lets you:

  • Quickly rule out the levels that work
  • Locate the responsible layer before digging
  • Communicate the state of the diagnosis clearly to the team
  • Repeat the same approach at every incident

Overview: the 4 diagnostic levels

LevelQuestion to askMain commands
1. ClusterIs the cluster reachable and healthy?kubectl cluster-info, kubectl get nodes
2. NodeIs a node in trouble?kubectl describe node, kubectl top nodes
3. PodWhy is this pod not working?kubectl describe pod, kubectl logs, kubectl debug
4. NetworkIs the traffic reaching the right place?kubectl get svc, kubectl get endpointslices, DNS check

The rule: start at the top and work down. If level 1 is healthy, move to level 2. If level 2 is healthy, move to level 3, and so on down to the network.

Level 1: is the cluster reachable?

Before anything else, check that you can talk to the API server and that the nodes are operational.

Check access to the cluster

Terminal window
kubectl cluster-info

Expected result:

Kubernetes control plane is running at https://192.168.122.50:6443
CoreDNS is running at https://192.168.122.50:6443/api/v1/namespaces/kube-system/services/coredns:dns/proxy

If this command fails, the problem is upstream of Kubernetes: network, kubeconfig, VPN, expired certificate. Check your ~/.kube/config file and the network connectivity to the API server.

Check the state of the nodes

A single NotReady node is enough to explain Pending Pods or unreachable applications. This check takes one command and one column to read. If all nodes are Ready, you rule out a whole family of causes.

Terminal window
kubectl get nodes
StatusMeaningAction
All ReadyThe cluster is generally reachable, but that does not rule out a control plane, kube-system or network problem. Keep triaging according to the symptomCheck kube-system and /readyz
One NotReady nodeProblem on that node → go to level 2Inspect the node
One SchedulingDisabled nodeMaintenance in progress (cordon)Normal if planned
No responseAPI server unreachableCheck the control plane

Check the control plane components

Terminal window
kubectl get pods -n kube-system -o wide

Check that etcd, kube-apiserver, kube-controller-manager and kube-scheduler are Running with RESTARTS at 0 (or very low).

For a finer diagnosis:

Terminal window
kubectl get --raw='/readyz?verbose' | grep -E '\[(\+|\-)\]'

Each [+] line confirms a working subsystem. A [-] line flags a failing component.

A kubectl that answers proves only one thing: the API server is reachable and your kubeconfig is valid. All the nodes can be NotReady, the scheduler can be stopped and the applications dead, and the command will still answer. That is why level 1 does not stop there.

Level 2: inspect a node in trouble

If a node is unexpectedly NotReady or SchedulingDisabled, inspect it in detail.

Read the node conditions

Terminal window
kubectl describe node <node-name>

The Conditions section reveals the cause. These are the warning signs:

ConditionAbnormal valueLikely cause
ReadyFalse or UnknownKubelet stopped, network cut, node overloaded
MemoryPressureTrueNot enough memory, pods too greedy
DiskPressureTrueFull disk (nodefs, imagefs or inodes)
PIDPressureTrueToo many processes on the node
NetworkUnavailableTrueCNI plugin not working

Check the node's resource consumption

Terminal window
kubectl top nodes

If a node shows CPU or memory close to 100%, pods may be getting evicted or may be unable to start.

Check the node's recent events

Terminal window
kubectl events --for node/<node-name> --types=Warning

Warning events on a node can reveal disk, kubelet or network problems that the conditions do not show yet.

Level 3: diagnose a pod

Triage starts by identifying the state of the pod, then you pick the command that matches the symptom.

Identify the state of the pod

Terminal window
kubectl get pods -n <namespace> -o wide
Observed statusMeaningNext action
PendingThe pod is not scheduled yet or not ready to start yetkubectl describe pod → look at Events (scheduling)
ContainerCreatingThe container is being createdWait, then kubectl describe pod if it persists
RunningAt least one container is runningCheck whether the application really answers
CrashLoopBackOffA container fails then restarts in a loopkubectl logs --previous, kubectl describe pod
ImagePullBackOffThe image cannot be downloadedkubectl describe pod → Events (pull errors)
ErrorA container stopped with an errorkubectl logs --previous, kubectl describe pod

OOMKilled does not appear in this table because it is not a pod status in the same sense as Pending or Running. It is a container termination reason, visible in kubectl describe pod under Last State. If you see frequent restarts with OOMKilled, increase limits.memory.

The 4 basic diagnostic commands

Four commands are enough to start a diagnosis: kubectl get, describe, logs and events. You have just used get; the following steps detail the other three, then kubectl exec, which serves for interactive inspection of the container, like kubectl debug further down.

  1. kubectl describe pod, the full view

    Terminal window
    kubectl describe pod <pod> -n <namespace>

    Sections to read first:

    • Events: messages from the scheduler, the kubelet, the probes
    • Last State: reason for the previous stop (OOMKilled, Error, etc.)
    • Exit Code: a clue about the nature of the crash
    • Containers → Env / Mounts: container configuration
    • Conditions: PodScheduled, Initialized, ContainersReady, Ready
  2. kubectl logs, the application logs

    Terminal window
    # Logs of the current container
    kubectl logs <pod> -n <namespace>
    # Logs of the previous run (the one that crashed)
    kubectl logs <pod> -n <namespace> --previous
    # Multi-container pod: specify the container
    kubectl logs <pod> -n <namespace> -c <container> --previous
    # Only the last 50 lines
    kubectl logs <pod> -n <namespace> --tail=50

    Look for: Exception, Error, panic, Traceback, connection refused, permission denied, OOM.

  3. kubectl events, the filtered events

    Terminal window
    # Events of a specific pod
    kubectl events --for pod/<pod> -n <namespace>
    # Warning events of the namespace
    kubectl events -n <namespace> --types=Warning

    Events complement the logs by showing what Kubernetes did (scheduling, image pull, kill by a probe, eviction).

  4. kubectl exec, get inside the container

    Terminal window
    kubectl exec -it <pod> -n <namespace> -- /bin/sh

    From inside the container, you check four things that no outside command shows:

    • Network connectivity: wget, curl, nslookup
    • The presence of the expected configuration files
    • The environment variables actually injected: env
    • The running processes: ps aux

    If the container has no shell (distroless image), use kubectl debug (see below).

Use kubectl debug (ephemeral containers)

Since Kubernetes v1.25, ephemeral containers are stable. They let you inspect a pod without changing its manifest, even if the image is minimal (distroless, scratch).

Terminal window
kubectl debug -it <pod> -n <namespace> --image=busybox:1.37@sha256:a7dbc319b1438115a207e11930dc4bb3e643dcb3ec0bdd694bb36cd8fad289ec --target=<container>

This command starts a busybox container attached to the existing Pod. It joins the Pod and shares at least its network context; access to the process space depends on the mode used, on --target and on the actual support of the runtime.

Available profiles with --profile:

ProfileWhat it allowsUse case
generalIsolated container in the podBasic network diagnosis
baselineLike general, more constrainedRestrictive environments
restrictedVery limitedClusters with a strict policy
netadminAdds the NET_ADMIN and NET_RAW capabilitiesAdvanced network diagnosis (tcpdump)
sysadminFull access (root, hostPID)Deep system diagnosis
Terminal window
# Advanced network diagnosis with tcpdump
kubectl debug -it <pod> -n <namespace> \
--image=nicolaka/netshoot:v0.16@sha256:b09d9b21381f47a79b3cbcb30da25266dc17186ea00ae65e99fdc51396f48e70 --profile=netadmin --target=<container>
# Diagnose a node directly
kubectl debug node/<node-name> -it --image=busybox:1.37@sha256:a7dbc319b1438115a207e11930dc4bb3e643dcb3ec0bdd694bb36cd8fad289ec

Level 4: diagnose the network (Services and DNS)

If the pod is running (Running) but the application is not reachable, the problem is often at the level of the Service, the DNS or the Network Policies.

Check the Service

Terminal window
kubectl get svc <service> -n <namespace>

Check that the TYPE, the CLUSTER-IP and the PORT match what you expect.

Check the EndpointSlices

Terminal window
kubectl get endpointslices -n <namespace> -l kubernetes.io/service-name=<service>

If the list of endpoints is empty, the Service finds no matching pod. Possible causes:

  • The Service selector (spec.selector) does not match the pod labels
  • The pods are not Ready (failed probe)
  • The pods are in another namespace

Check DNS resolution

From a test pod:

Terminal window
kubectl run dnstest --image=busybox:1.37@sha256:a7dbc319b1438115a207e11930dc4bb3e643dcb3ec0bdd694bb36cd8fad289ec --rm -it --restart=Never -- \
nslookup <service>.<namespace>.svc.cluster.local

Expected result: the name resolves to the Service IP (CLUSTER-IP).

If resolution fails:

Terminal window
# Check that CoreDNS is working
kubectl get pods -n kube-system -l k8s-app=kube-dns
# Check the CoreDNS logs
kubectl logs -n kube-system -l k8s-app=kube-dns --tail=20

Test end-to-end connectivity

Terminal window
kubectl run curltest --image=curlimages/curl:8.21.0@sha256:7c12af72ceb38b7432ab85e1a265cff6ae58e06f95539d539b654f2cfa64bb13 --rm -it --restart=Never -- \
curl -v http://<service>.<namespace>.svc.cluster.local:<port>/

If DNS works but the connection fails, check:

  • The target port (targetPort) in the Service definition
  • The Network Policies that might block the traffic
  • kube-proxy (iptables/IPVS mode) on the nodes

The last suspect is the most discreet: Network Policies block traffic without any error message, on the sender side as well as on the receiver side. A connection that times out for no apparent reason in a namespace that has some deserves a kubectl get networkpolicies -n <namespace>, followed by a read of the ingress and egress rules.

Quick decision tree

Use this tree when you face a symptom and do not know which level to start with. It asks the questions in the order of the method, from the cluster to the network: a symptom at a higher level is handled before looking lower.

Each question has its "yes" exit on the same line, with the level concerned and the first command to run; only a "no" takes you down. The last exit, in grey, covers the symptom that no question recognizes: you start over at level 1 rather than guess.

Decision tree in five questions: if kubectl does not answer, level 1 cluster, check kubeconfig, network and VPN; otherwise, if a node is NotReady or Pods are evicted for no reason, level 2 node with kubectl describe node; otherwise, if a Pod is Pending or in ImagePullBackOff, level 3 pod with kubectl describe pod and its Events; otherwise, if a Pod is in CrashLoopBackOff, level 3 pod with kubectl logs --previous; otherwise, if a Running Pod is unreachable or suffers intermittent timeouts, level 4 network with get svc, endpointslices, DNS and NetworkPolicies; otherwise, start over at level 1.A symptomin productionkubectl doesnot respond?Node NotReady, or Podsevicted for no clear reason? no Level 1, cluster:kubeconfig, network, VPN yes Pod Pending orImagePullBackOff? no Level 2, node:kubectl describe node yes Pod inCrashLoopBackOff? no Level 3, pod:kubectl describe pod (Events) yes Pod Running but unreachable,or intermittent timeout? no Level 3, pod:kubectl logs --previous yes Level 4, network: get svc,endpointslices, DNS, NetworkPolicies yes Unrecognised symptom:start again at level 1 no 
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %

The table gives the same mapping as a list of symptoms, handy for finding a row at a glance:

SymptomProbable levelFirst command
kubectl does not answer1, ClusterCheck kubeconfig, network, VPN
NotReady node2, Nodekubectl describe node <node>
Pending pod3, Podkubectl describe pod <pod> (Events)
CrashLoopBackOff pod3, Podkubectl logs <pod> --previous
ImagePullBackOff pod3, Podkubectl describe pod <pod> (Events)
Running pod but application unreachable4, Networkkubectl get svc, kubectl get endpointslices
Intermittent timeout4, NetworkDNS check + Network Policies
Pods evicted for no apparent reason2, Nodekubectl describe node (conditions, pressure)

Quick troubleshooting

This table does not replace the four levels: it is for when you recognize the symptom and want to go straight to the right place. When in doubt, start over at level 1: a cause searched for at the wrong level wastes more time than one extra step.

SymptomProbable causeSolution
kubectl timeoutAPI server unreachableCheck kubeconfig and network connectivity
Persistent NotReady nodeKubelet stopped or full diskSSH to the node, systemctl status kubelet
Pending pod for a long timeNo node with enough resourceskubectl describe pod → Events → adjust requests or add a node
Empty logs + exit code 137OOMKill (visible in Last State of describe)kubectl describe pod → increase limits.memory
Empty logs + exit code 127Binary not found in the imageCheck command: and the image tag
Running pod but connection refusedMisconfigured Service or pod not ReadyCheck the Service selector and the probes
DNS does not resolveCoreDNS downkubectl get pods -n kube-system -l k8s-app=kube-dns
Traffic blocked without errorRestrictive Network Policykubectl get networkpolicies -n <namespace>

Key takeaways

  • Always start at the top: cluster → node → pod → network. This avoids wasting time reading logs when the problem is a failed node
  • The 4 basic commands are kubectl get, describe, logs and events. kubectl exec and kubectl debug then complete them for interactive inspection
  • kubectl logs --previous is often forgotten: it shows the logs of the run that crashed, not the current one
  • kubectl debug with ephemeral containers lets you inspect a pod without restarting it, even on a distroless image
  • Network problems are often configuration problems: wrong Service selector, failing probe, blocking Network Policy
  • Document your diagnosis: write down the commands you ran and their results, it helps to communicate with the team and to build runbooks

Knowledge check

Seven questions on the discipline of the method: what a command that answers really proves, what an empty EndpointSlice means, and why a NetworkPolicy never announces itself.

Knowledge check

Check what you have learned with this interactive quiz

7 questions
5 min
80% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer