Lab & Completion
What You Will Produce
On your own kind cluster, the Guardian’s limits proven and one alert followed from Alertmanager to a closed incident. You ask the API server what the Guardian may do, and its API what it gives to a caller without a token. Then you send a test alert through Alertmanager - with a fake password in its text - and find the incident it became: what was collected, that the password was redacted, and, if you gave the Guardian an LLM key, the analysis, which you check against the cluster like any hypothesis. You acknowledge the incident, end the alert, and watch the Guardian close it.
Before You Start
The baseline from Chapter 00 must be clean:
flux --context kind-sre-control-plane get kustomizations -A # every row READY=True and SUSPENDED=False
kubectl --context kind-sre-control-plane get pods -A --no-headers | grep -vE 'Running|Completed' # prints nothing
make smoke-test # Fail: 0
You need three terminals, curl and jq. If kubectl --context kind-sre-control-plane -n observability get alertmanagerconfig guardian says NotFound, your fork is older than the chapter: on GitHub, open your fork and click Sync fork → Update branch, then git switch main && git pull, let Flux catch up, and run make kind-plan and make kind-apply once - Terraform creates the Guardian’s Secret.
An LLM key is optional. Without one the Guardian does everything in this lab except the analysis - B3 tells you what to look at instead. To see an analysis, put your own key into infra/terraform/kind_cluster/terraform.tfvars (Git ignores the file; the key never goes into Git or into a chat):
guardian_llm_provider = "gemini" # or "openai" or "anthropic"
guardian_llm_api_key = "<your key>"
Then make kind-plan, make kind-apply, and kubectl --context kind-sre-control-plane -n observability delete pod -l app.kubernetes.io/name=k8s-ai-monitor - the Guardian reads its key when it starts, and its ReplicaSet starts a new pod. Not kubectl rollout restart: Flux manages the Deployment and removes the annotation that command adds - mid-rollout, the old pod stays with the old key (Chapter 21). Deleting the pod changes nothing Flux manages. Wait until the new one is Ready before the lab: for i in $(seq 1 30); do kubectl --context kind-sre-control-plane -n observability wait pod -l app.kubernetes.io/name=k8s-ai-monitor --for=condition=Ready --timeout=10s && break; sleep 2; done (up to about 6 minutes; no matching resources found means no pod yet - if it never comes, kubectl --context kind-sre-control-plane -n observability get events --sort-by=.lastTimestamp | tail -5 says why). One analysis costs a fraction of a cent. The Gemini API’s free tier - a project without a billing account - costs nothing. On it, outside the EEA, Switzerland and the UK, Google may use what you send to improve its products; inside them, and on any project with an active billing account (a paid tier), it does not. Either way, this lab’s invented alert is fine to send - a real cluster’s data is not.
The Lab in Three Parts
- A. Verify - the Guardian’s mode, what it may do in the cluster, what its API gives without a token, the route from Alertmanager.
- B. Break & Fix - a test alert with a fake password; the incident, its context and its analysis checked against the cluster; acknowledged, ended, closed.
- C. Rollback & Cleanup - no test alert left, the port-forwards closed, the baseline proven.
Done When
- the Guardian’s log said whether it has an LLM key, and its API was protected (A1, A4)
- as the Guardian,
get podswas allowed,patch deploymentsandget secretsrefused, and its full list held nothing but read verbs and the self-review questions (A3) - without a token its API answered
403, with the token200(A4) - the AlertmanagerConfig
guardianwas there, next tosafeops-routing(A5) - your test alert became one incident in
production(B2) - the fake password was redacted in what the Guardian printed or sent (B3)
- with a key, you checked one piece of the analysis’s evidence in the cluster and wrote down whether it held; without one, you saw the incident posted without an analysis (B4)
- the incident went
active→acknowledged→resolved- the last step by the ended alert, not by you (B5) - no test alert is left, and the baseline is clean (C1-C2)
Knowledge Check
Before finishing this chapter, complete the Quiz.