Troubleshooting Clusters and Workloads

Topics Covered

A Systematic Method for Troubleshooting Tasks

Work from the symptom down the layers

The four reads

Events are short lived

Read the controller chain

One change, then verify

Know what the task is asking for

Useful output shapes

Time management on troubleshooting tasks

Keep notes as you go

Do not trust the task's own diagnosis

Troubleshooting carries the largest single weight in the CKA curriculum, about thirty percent, and it runs through the CKAD too, where debugging an application is part of the observability domain. The tasks look different every time: a pod that will not start, a Service that returns nothing, a node that has gone NotReady, a control plane component that has stopped. What they share is that a method beats memory. A candidate who follows the same short sequence of reads every time finds the cause faster than one who jumps to a guess, and much faster than one who changes three things at once and cannot tell which one helped.

This lesson builds that method and then applies it layer by layer: pods first, then Services and connectivity, then nodes, then the control plane and resource usage. It refers to earlier lessons rather than repeating them. Probes were covered with pods, scheduling rules with scheduling, CoreDNS and NetworkPolicies with networking, and static pods with cluster installation. Here the focus is on finding which of those is wrong, quickly.

Work from the symptom down the layers

A Kubernetes failure almost always shows up at the top, as an application that does not work, while the cause can be at any layer below. Think of four layers. The workload layer is pods, containers and their configuration. The service layer is Services, endpoints, DNS and network policy. The node layer is the kubelet, the container runtime and the host. The control plane layer is the API server, etcd, the scheduler and the controller manager. Start at the layer where the symptom appears and move down only when the evidence points there. A pod in CrashLoopBackOff is almost never a control plane problem; a cluster where kubectl itself fails almost always is.

The four reads

For any object that is misbehaving, four reads give you nearly everything:

bash
1kubectl get pods -n shop -o wide                 # status, restarts, node, IP
2kubectl describe pod web-7d9c -n shop            # spec, conditions, events
3kubectl logs web-7d9c -n shop --previous         # output of the last crashed container
4kubectl get events -n shop --sort-by=.lastTimestamp

get shows the state in one word, such as Pending, CrashLoopBackOff, ImagePullBackOff, Error or Completed, plus the restart count and which node the pod landed on. describe shows the full picture: container states with their last exit code and reason, conditions such as Ready and PodScheduled, the volumes and environment, and at the bottom the events for that object. Events are the cluster narrating what it tried: scheduling decisions, image pulls, probe failures, kills. logs shows what the application itself printed. Between them, these four reads identify the cause of most workload failures in under a minute.

Every troubleshooting task follows the same loop: status, events, logs, then one fix and a check.

Events are short lived

Events are stored as ordinary objects with a default time to live of one hour on the API server. A problem that started two hours before you looked may have no events left, and describe will show none. That is a clue in itself: an object with no recent events is not being actively retried or rejected right now. The newer kubectl events command is a friendlier view than get events. It sorts by time and can filter to one object or to warnings:

bash
kubectl events -n shop --for pod/web-7d9c
kubectl events -A --types=Warning
kubectl get events -n shop --field-selector involvedObject.name=web-7d9c

Warning events across all namespaces are a fast first look at an unfamiliar broken cluster, because they show everything the system is unhappy about in one list.

Read the controller chain

Most pods are created by controllers, and a problem can sit at any link of the chain: Deployment to ReplicaSet to Pod. If a Deployment shows zero ready replicas and there are no pods at all, the pods are not crashing; they were never created. describe the ReplicaSet, whose events will say why it could not create pods, for example a quota exceeded or a service account that does not exist. If there is no ReplicaSet either, the controller manager may be down, which is a control plane problem. Following the chain takes three commands and stops you from staring at pods that do not exist.

bash
kubectl get deploy,rs,pods -n shop -l app=web
kubectl describe rs -n shop -l app=web | tail -20

One change, then verify

When you find the cause, make the smallest change that fixes it and check the result before doing anything else. Fixing a Deployment means editing the Deployment, not the pod, because the controller replaces pods with the template's version. After the change, watch the rollout and read the status again. If the state did not change, you found a symptom, not the cause; go back to the reads. Changing several fields at once makes it impossible to know which was needed, and on the exam it risks breaking a part of the object that the grader also checks.

bash
kubectl edit deploy web -n shop        # or kubectl set image / set env / patch
kubectl rollout status deploy/web -n shop
kubectl get pods -n shop -l app=web

Know what the task is asking for

Troubleshooting tasks come in three forms, and the wording tells you which. Fix the problem means the grader checks the end state: pods running, a Service answering, a node Ready. Find the cause and write it to a file means the grader reads your file, often for a specific word such as the name of a pod or the failing component. Identify the pod using the most CPU and write its name to a path means a read and a redirect, with no fix needed. Do exactly the form the task asks. Writing a perfect explanation to a file earns nothing when the task asked for a working Service, and fixing a pod that you were only asked to identify can remove the evidence the grader expected.

Useful output shapes

A few output options save typing during diagnosis. Wide output adds the node and IP. show-labels prints labels next to pods, which is the fastest way to spot a selector mismatch. jsonpath and custom columns pull one field across many objects, such as the last termination reason of every container:

bash
kubectl get pods -A -o wide --field-selector status.phase!=Running
kubectl get pods -n shop --show-labels
kubectl get pods -n shop -o custom-columns=NAME:.metadata.name,REASON:.status.containerStatuses[0].lastState.terminated.reason

The field selector on status.phase is a quick way to list every pod that is not Running across the whole cluster, which is often the first command to run when a task says something is broken somewhere in a namespace you have not seen. Completed Job pods will appear too, because their phase is Succeeded; ignore those.

Time management on troubleshooting tasks

These tasks have the widest spread of solve times. A missing label takes two minutes; a broken kubelet on a node you have to reach over ssh can take ten. Set yourself a limit, for example twelve minutes, and if you have not found the cause by then, flag the task and move on. Come back with fresh eyes after the easier tasks are banked. Often the second look finds in a minute what the first look missed, because you stop assuming and start reading again.

Keep notes as you go

On a long troubleshooting task, write down what you have ruled out. A line in a scratch file such as node fine, image fine, env missing DB_HOST takes five seconds and stops you from repeating the same check after a distraction. It also helps when you flag a task and come back later: your notes tell you exactly where you stopped, so the second visit starts from the evidence rather than from the beginning. The exam's remote desktop has a notepad, and a terminal heredoc into a file in your home directory works just as well.

Do not trust the task's own diagnosis

Some tasks describe the symptom with a guess attached, such as the database seems to be down. Treat the guess as a hint, not a fact. Check the database pod, but also check what the client actually sees. Often the database is fine and the client has the wrong Service name, or the database is fine and its Service lost its selector. Following the evidence, rather than the wording, is what the troubleshooting domain is really testing.

What strong candidates do differently

A passing candidate fixes the pod in front of them. A strong candidate reads status, events and logs before touching anything, follows the controller chain when there are no pods, makes one change and verifies it. That discipline is what holds up on the hardest troubleshooting tasks.