Appearance

Capstone: recover a stateless app

Recover a stateless app by identifying the failed link between a Service and its ready Pods.

What you will understand

  • Collect Pod, Service, and endpoint evidence for the same request.
  • Repair the selector that excludes the intended healthy backends.
  • Demonstrate recovery from the original client and record what changed.

Builds on: Protecting Secrets and tenant boundaries, Capacity and scale trade-offs, Service meshes and platform boundaries

Investigate a healthy app that clients cannot reach

You are on call for a small web app. The Deployment reports ready Pods, but a client in the same namespace cannot load the page. Your task is to find the first failed link in the request path, change only what is needed, and prove the page is reachable again. You will use the Pod and Service concepts from foundations together with the evidence-gathering workflow from the debugging modules.

Start by checking that you are in the disposable cluster and using the kv-lab namespace. Use the failure scene to predict which evidence shows whether the Pods are ready and whether the Service routes to them. In this incident, a DNS answer can succeed because the Service exists. The request can still fail because its backend set is empty.

Why can healthy Pods still be unreachable?

The Deployment and Pods are healthy, but the Service selector does not match those Pods. The failed client request points toward the mapping.

  1. The Pods are ready

    • m20-clientRequests http://m20-web
    • Service m20-webselector broken-selector
    • EndpointSlice setNo usable matching backends
    • nginx PodsReady, app=m20-web
    • Cluster DNSResolves Service identity

    Two nginx Pods become Ready with app=m20-web labels.

  2. The Service selects a different label

    The Service selector is app=broken-selector, so those Ready Pods do not become its usable backends.

  3. The original caller still fails

    The client can address the Service but cannot reach selected application backends through this relationship.

Exact client error and dataplane forwarding differ by networking implementation; the label mismatch is implementation-independent.

Explore another case

Find and repair the selector mismatch

The example Service is intentionally broken. It selects app: broken-selector. The Deployment’s Pods carry app: m20-web. Inspect the labels and the Service selector together, and use EndpointSlices to check which eligible addresses are actually published. Try the request from m20-client using http://m20-web. Note the result rather than relying only on status columns.

apiVersion: v1
kind: Service
metadata:
  name: m20-web
  namespace: kv-lab
  labels:
    lab: m20
spec:
  selector:
    app: broken-selector # Deployment Pods actually use app=m20-web.
  ports:
    - port: 80
      targetPort: 80

Predict what will change after replacing the Service selector with app: m20-web. The Service name and existing healthy Pods can stay in place. The endpoint controller can publish matching backend addresses. Wait for those endpoints to be eligible, then repeat the original request. Trace the change in the recovery scene.

Prove the stateless app recovered from the original client

Change the selector, check for a ready endpoint, then run the same HTTP request to verify the repair.

  1. OperatorFix the selector to match app=m20-web
    ServiceThe Service now selects the intended Pods.
  2. EndpointSlice controllerPublish matching addresses
    Forwarding implementationThe corrected endpoints become available to route traffic.
  3. Original client PodRepeat the original HTTP request
    Recovered appA successful response verifies the request path end to end.
Follow the sequence

Change the selector, check for a ready endpoint, then run the same HTTP request to verify the repair.

The actual capstone uses matching port 80; the alternate branch is a separate diagnostic hypothesis.

Inspect the recovered request path

Take an on-call investigation from the first failing request to the client’s proof of recovery. Keep the existing healthy Pods in place.

1 / 5

From Probe clientTo Service

Confirm the client’s request fails

The client can address the Service, but its HTTP request fails. The application’s Deployment still has two Ready replicas.

Ready Pods / client result
Before
2 Ready / checking request
After
2 Ready / HTTP fails
Confirm the client’s request fails

The client can address the Service, but its HTTP request fails. The application’s Deployment still has two Ready replicas.

Uses the stateless capstone’s resource names. Endpoint propagation and the wait before retrying are compressed.

What result best shows that users can reach the app again?
Reveal prediction answer

A successful retry from the same client to the same Service proves the whole request path. Endpoint state tells you just one part of that path is ready.

Save the initial request result, the selector mismatch, the recovered endpoints, and the final HTTP response.

Run the stateless recovery capstone
Explore another case

Open Inspect the recovered request path to follow the evidence you will collect during the capstone. Keep the original client and URL for the final retry.

Record the recovered request path

Download all module files and follow the stateless capstone. This script sets up the deliberate failure, proves the request fails, repairs the selector, and verifies the response. Pause to predict before following the solution, or run the guided stages described in the lab. Keep a short record of the original symptom, the Pods’ actual labels, the correction, the EndpointSlice evidence, and the response seen by the same client.

# Download all m20 files first, then run only this investigation.
bash capstone-stateless.sh
# Read-only follow-up evidence after the script's repair.
kubectl --context kind-kv-lab -n kv-lab get pods -l app=m20-web --show-labels
kubectl --context kind-kv-lab -n kv-lab get service m20-web -o yaml
kubectl --context kind-kv-lab -n kv-lab get endpointslices -l kubernetes.io/service-name=m20-web -o yaml
kubectl --context kind-kv-lab -n kv-lab exec m20-client -- wget -qO- -T 3 http://m20-web

Fix the resource that owns the setting

Restarting already-ready Pods would leave the wrong selector in place. Relabeling those Pods by hand could produce a temporary match and leave the Deployment template wrong for future Pods. Fix the configuration relationship that caused the incident, and check that it still works after a healthy copy is replaced if you want to go further.

Check your understanding

The repaired Service now has endpoint addresses. What is the strongest final check?

Request the original URL from m20-client and verify the expected content. Endpoint addresses show that the mapping recovered. The same client’s response exercises DNS, forwarding, and the backend together.

Go to the source

Reviewed 2026-10-27 · Kubernetes 1.37 · Related local exercise

Search the book

Search loads when you open it.

Keyboard shortcuts

Ctrl + K / ⌘ + K
Search the book
?
Open this guide
Tab / Shift + Tab
Move between controls
Enter / Space
Activate a focused button or disclosure
← / →
Focused visual timeline · previous or next step
Home / End
Focused visual timeline · first or last point
Esc
Close the open dialog or menu