StaffCoder
Kubernetes
15 modules · 60 challengesSign up
Module 2 · kubectl Inspection & Debugging

Events & Field Selectors

easyKubernetes EventsField Selectors & Diagnosis—No data yet

Problem statement

A pod has been Pending for an hour and the on-call is reading source code to guess why, while the cluster has been saying why the whole time. Three workloads in namespace triage are stuck for three different reasons. Find them in the record.

About this exercise

An event is the cluster's own note about something that happened to an object: it was scheduled, its image was pulled, it could not be placed, its container could not be created. Every event carries the object it is about, a reason (a short machine-readable code), a message, and a type - Normal for routine progress, Warning for trouble. Events expire after about an hour, which is why reading them early matters.

Listing every event in a busy namespace is noise. Field selectors filter server-side on the event's own fields - which object it involves, its reason, its type - so you can go from "something is wrong here" to "this object, this reason" in one command. kubectl get events --help shows the syntax; the fields you can select on are the ones you see in kubectl get events -o yaml.

A stuck pod also carries a waiting reason in its container status, which usually names the same problem the events describe.

The three broken workloads are report-batch, search-indexer and pricing-api. The namespace also holds healthy workloads and one that failed a few times before recovering - neither belongs in your diagnosis.

How this project is graded

The grader checks your saved listings and compares your diagnosis against the reasons the cluster actually recorded. Everything here is read-only.

What you will build

Three answers in answers/, listed in answers/questions.md:

report-batch-events.txt   the events belonging to pod report-batch, and no others
warnings.txt              every warning-type event in the namespace
diagnosis.txt             one line per stuck pod:  <pod-name> <event-reason>

Step 1 - one object's story

Filter the event listing down to a single pod's events - not by grepping the full list, but by asking the API for that object's events.

events_filtered_to_one_object_only should pass

Step 2 - only the trouble

Filter the namespace's events down to the warnings, so the routine progress notes disappear.

warning_filter_isolates_the_problems should pass

Step 3 - name each cause

For each of the three stuck pods, write the reason the cluster recorded for it. Exactly three lines - the healthy workloads and the recovered one are not part of this.

unschedulable_pod_diagnosed, image_pull_failure_diagnosed, config_failure_diagnosed and diagnosis_covers_exactly_the_broken_pods should pass

When every test passes

You have:

  • The cluster's own explanation for each stuck workload, instead of a guess
  • Event listings filtered server-side to one object or one severity
  • Three distinct failure modes recognized by their reasons: nothing can place it, its image cannot be fetched, its configuration does not exist
  • A diagnosis that names only what is actually broken

You do not have yet:

  • All of it as one on-call tool. A read-only sweep that reports placement, evidence and diagnosis for a whole namespace is the next challenge.

Verify

Click Test after every step.

More in kubectl Inspection & Debugging

See the module
Reading Cluster StateAnswer real questions about a running namespace with get and describe - wide placement, exact field extraction, sorted listings and the events section.—No data yeteasyLogs & ExecRead what containers actually said - current and previous instances, tail limits, the right container - and check in-container truth with exec.—No data yeteasyCluster Triage KitOne read-only sweep over a namespace: placement and state, log and in-container evidence, and an event-rooted diagnosis for every broken workload.—No data yeteasy

We use cookies that are necessary to run Staffcoder, and optional analytics cookies to see which pages get used. Analytics stays off unless you accept. Read our Cookie Policy.