Skip to content
Hands-on IT IT Drills

Appendix B: Final Exam

Goal: Four tasks without instructions that bring together everything from the book. · Duration: approx. 75 min · Prerequisite: Days 0–15

Rules of Play

  • You work in the fleet repo and in ~/flux-lab/team-gruen. Every change to the cluster goes through Git or through a team artifact, never through kubectl apply.
  • Every task has check commands. Only when they show what is stated there is the task solved.
  • The solutions are in ~/flux-lab/code/loesung/pruefung/.

Exercise 1: dev goes into hibernation

dev should be paused, but not with flux suspend; instead, in a way that is in Git and visible to everyone. Only the Kustomization notes-dev, not the database.

Check:

flux get kustomization notes-dev

Expected (shortened):

NAME        REVISION            SUSPENDED   READY   MESSAGE
notes-dev   main@sha1:9a6e2ef2  True        True    Applied revision: main@sha1:9a6e2ef2

Solution

In clusters/lab/notes-dev.yaml, the second Kustomization (notes-dev) gets one line under spec:

  suspend: true

flux suspend sets exactly this field, but only in the cluster. If it is in Git, it persists through every reconciliation and every rebuild. A comment in the commit says why.

Save your progress? Sign up for free

Exercise 2: Three replicas for notes-helm

notes-helm should run with three replicas. Change only a single line for this, and the HelmRelease should pick it up without flux reconcile helmrelease.

Check:

kubectl -n notes-helm get deploy notes
helm -n notes-helm history notes | tail -1

Expected (shortened):

NAME    READY   UP-TO-DATE   AVAILABLE   AGE
notes   3/3     3            3           74m
13          Thu Nov 12 17:33:53 2026    deployed    notes-0.4.0+5de96b4085b8    0.7.1       Upgrade complete

Solution

sed -i 's/^replicas: 2/replicas: 3/' apps/notes-helm/values.yaml

This gives the ConfigMap from the configMapGenerator a new hash in its name, the nameReference from Day 6 writes it into the HelmRelease, and the changed HelmRelease triggers the upgrade.

Save your progress? Sign up for free

Exercise 3: Team grün listens in

Team grün wants to see the events of its own Kustomization apps in the echo server, including the successful ones. The lockdown from Day 12 stays active.

Check:

flux get alerts -n team-gruen

Expected:

NAME    SUSPENDED   READY   MESSAGE
apps    False       True    Alert is Ready

Solution

The Provider and Alert have to live in the team’s namespace. Because of --no-cross-namespace-refs, an Alert in team-gruen may not point to the Provider echo in flux-system:

cat > tenants/team-gruen/alerts.yaml <<'EOF'
---
apiVersion: notification.toolkit.fluxcd.io/v1
kind: Provider
metadata:
  name: echo
  namespace: team-gruen
spec:
  address: http://echo.echo.svc.cluster.local/
  type: generic
---
apiVersion: notification.toolkit.fluxcd.io/v1
kind: Alert
metadata:
  name: apps
  namespace: team-gruen
spec:
  eventSeverity: info
  eventSources:
  - kind: Kustomization
    name: apps
  providerRef:
    name: echo
EOF

An address in another namespace is allowed. The restriction applies to references to Flux objects, not to URLs.

Exercises 1 to 3 go into one commit:

git add -A
git commit -m "Prüfung 1-3"
git push
flux reconcile kustomization flux-system --with-source
flux reconcile kustomization tenants
flux reconcile kustomization notes-helm

Save your progress? Sign up for free

Exercise 4: Team grün moves

Team grün replaces its handwritten notes-api with a NotesApp named gruen on port 30095, with the API key gruen-key-123456. Afterwards the old app should be gone, without anyone from the platform deleting anything.

Check:

kubectl -n team-gruen get notesapp,deploy
curl -s localhost:30095/version; echo
curl -s -o /dev/null -w '%{http_code}\n' localhost:30093/version
kubectl -n echo logs deploy/echo --since=2m | grep -E '^        "message"' | head -2

Expected (shortened):

NAME                             STATE    READY   AGE
notesapp.lab.example.com/gruen   ACTIVE   True    19s
NAME                    READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/gruen   1/1     1            1           19s
0.7.1
000
        "message": "NotesApp/team-gruen/gruen created",
        "message": "Deployment/team-gruen/notes deleted\nService/team-gruen/notes deleted\nSecret/team-gruen/notes-api deleted",

Solution

cd ~/flux-lab/team-gruen
rm app.yaml
cat > notesapp.yaml <<'EOF'
apiVersion: lab.example.com/v1alpha1
kind: NotesApp
metadata:
  name: gruen
spec:
  apiKey: gruen-key-123456
  nodePort: 30095
EOF
flux push artifact oci://localhost:30500/team-gruen/apps:1.1.0 --path=. \
  --source=local --revision=1.1.0 --insecure-registry
flux reconcile source oci apps -n team-gruen
flux reconcile kustomization apps -n team-gruen
  • prune: true in the team’s Kustomization removes the old app, because it is no longer in the artifact.
  • 000 means: nobody answers on port 30093 anymore.
  • The messages in the echo server come from Exercise 3. The team sees its own move.

Save your progress? Sign up for free

You made it

If all four exercises pass their check commands, you have completed your drills. You can:

  • install, extend and upgrade Flux with flux bootstrap,
  • roll out manifests from Git, OCI and Helm repos and make them depend on each other in a sensible order,
  • separate environments with overlays and variables and promote versions,
  • encrypt Secrets with SOPS and rotate keys,
  • find new images automatically and roll them out via commit or pull request,
  • have Flux send notifications and trigger it via webhook,
  • separate teams from each other securely,
  • check a fleet repo in CI and investigate Flux in operations.

Clean up when you no longer need the lab. First on GitHub: repository flux-fleet → Settings → Delete this repository, and delete the token flux-lab under Developer settings. Then the VM:

exit
multipass delete --purge flux