Skip to content
Kubernetes tools · Chapter 17 of 20 Day 15: Competition – the Sabotaged Shop

Day 15: Competition – the Sabotaged Shop

Goal: In five rounds, find and fix hidden faults in the Werkzeugladen (tool shop), each with the tool that leads to the cause fastest: logs, network, hygiene, permissions, Helm. Against the clock, with a measurement as proof · Duration: approx. 90 min · Prerequisite: Days 0–14

Briefing

  • The playing field is the shop as it stands after Day 14: web, api, cache, kasse (checkout), lieferung (delivery), werkbank (workbench) and netshoot in laden (shop), packer and inventur (stocktaking) in lager (warehouse), Headlamp, Hubble, Goldilocks.
  • Five times, something breaks. You only see what a colleague reports. Which tool you use is your decision; the solution shows the shortest path, not the only one.
  • The tools from 14 days: kubectl queries, k9s, stern, kubectl debug, netshoot, Hubble, Popeye, kube-linter, Kubescape, rbac-tool, helm-diff and your own plugin.
Round  Report                                                          Target time
1      “The checkout keeps restarting”                                 5 min
2      “The workbench can no longer reach the web shop”                5 min
3      “The cache is gone, but Redis is running”                       4 min
4      “Something in the warehouse namespace has too many permissions” 6 min
5      “Headlamp now has two Pods. Intended. But the audit …”          6 min

Rules of the Game

  • In each round, the referee runs their commands, either a colleague or you yourself without looking: copy the block, paste it into a second terminal, close the window. Then start the clock.
  • Find the cause, fix it, prove it with the round’s measurement. Only then stop the clock.
  • Fix the cause, not the symptom: whoever deletes a policy instead of correcting it, or rebuilds the cluster, gets zero points for the round.
  • Read the hint only when the target time has run out.
  • For Round 2 you need Hubble. If cilium hubble port-forward from Day 8 is no longer running, start it beforehand in a separate terminal.

Playing Field

Once before the first round, the overall state. The same lines are the scoring at the end.

mkdir -p ~/werkzeuge/tag15 && cd ~/werkzeuge/tag15
echo "Kasse-Neustarts: $(kubectl -n laden get pods -l app=kasse -o jsonpath='{.items[*].status.containerStatuses[0].restartCount}')"
echo "Web: $(kubectl -n laden exec werkbank -- wget -qO- -T3 http://web/ | grep -o '<title>.*</title>')"
echo "Cache: $(kubectl -n laden exec netshoot -- sh -c "printf 'PING\r\n' | nc -w2 cache 6379" | tr -d '\r')"
echo "Lager liest kube-system-Secrets: $(kubectl auth can-i get secrets -n kube-system --as=system:serviceaccount:lager:default)"
echo "Headlamp-Admin-Bindung: $(kubectl get clusterrolebinding headlamp-admin --ignore-not-found -o name | wc -l)"

Expected:

Kasse-Neustarts: 0 0
Web: <title>Welcome to nginx!</title>
Cache: +PONG
Lager liest kube-system-Secrets: no
Headlamp-Admin-Bindung: 0

Redis answers with \r\n at the end of the line; tr -d '\r' removes the carriage return so that the output stays readable.

Round 1: The Checkout Keeps Restarting

Referee:

kubectl -n laden patch deploy kasse --type=json -p '[{"op":"remove","path":"/spec/template/spec/containers/0/volumeMounts"},{"op":"remove","path":"/spec/template/spec/volumes"}]' >/dev/null
kubectl -n laden rollout status deploy/kasse --timeout=90s >/dev/null
sleep 70
clear

Symptom:

NAME                    READY   STATUS    RESTARTS      AGE
kasse-f59678576-6nmtv   1/1     Running   2 (23s ago)   75s
kasse-f59678576-9zhrl   1/1     Running   2 (28s ago)   80s

Hint: The cause is in the log, but not in a line with ERROR. Day 7.

Solution Round 1

Do not search for what you expect; hide what you know:

stern -n laden kasse --since 2m --no-follow --exclude INFO 2>/dev/null | grep -v WARN | head -4

Expected (names and times will differ):

kasse-f59678576-9zhrl kasse sh: can't create /daten/abschluss.log: nonexistent directory
kasse-f59678576-9zhrl kasse 2026-11-24T14:34:02+00:00 ERROR tagesabschluss fehlgeschlagen

The same picture as on Day 7: /daten is missing, and the volume has disappeared from the Deployment. Add it back, with the same patch as back then:

kubectl -n laden patch deploy kasse --type=strategic -p '{"spec":{"template":{"spec":{"volumes":[{"name":"daten","emptyDir":{}}],"containers":[{"name":"kasse","volumeMounts":[{"name":"daten","mountPath":"/daten"}]}]}}}}'
kubectl -n laden rollout status deploy/kasse --timeout=90s

Measurement (after 40 seconds, so that the twelfth receipt has gone through):

kubectl -n laden get pods -l app=kasse
stern -n laden kasse --since 35s --no-follow --include "tagesabschluss|ERROR" 2>/dev/null

Expected:

NAME                    READY   STATUS    RESTARTS   AGE
kasse-866c4ff85-bf7dp   1/1     Running   0          46s
kasse-866c4ff85-fz9xq   1/1     Running   0          50s
kasse-866c4ff85-bf7dp kasse 2026-11-24T14:34:38+00:00 INFO tagesabschluss nach /daten/abschluss.log
kasse-866c4ff85-fz9xq kasse 2026-11-24T14:34:33+00:00 INFO tagesabschluss nach /daten/abschluss.log

kubectl -n laden rollout undo deploy/kasse would also be a clean fix, because the revision before was the right one. In that case, first check with kubectl rollout history --revision=… that it also contains the requests from Day 9.

Save your progress? Sign up for free

Round 2: The Workbench Cannot Reach the Web Shop

Referee:

cat <<'EOF' | kubectl apply -f - >/dev/null
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: standard-absicherung
  namespace: laden
spec:
  podSelector:
    matchLabels: {tier: frontend}
  policyTypes: [Ingress]
  ingress:
  - from:
    - namespaceSelector:
        matchLabels: {kubernetes.io/metadata.name: ingress-nginx}
EOF
clear

Symptom:

kubectl -n laden exec werkbank -- wget -qO- -T3 http://web/
wget: download timed out
command terminated with exit code 1

Hint: Timeout, not refused. Who drops, and with which rule? Day 8.

Solution Round 2

hubble observe -n laden --verdict DROPPED --last 3 -o compact
kubectl -n laden get netpol

Expected (shortened):

Nov 24 14:35:09.085: laden/werkbank:52646 (ID:1151) <> laden/web-67649cfddb-6d48k:80 (ID:44488) Policy denied DROPPED (TCP Flags: SYN)
Nov 24 14:35:10.108: laden/werkbank:52646 (ID:1151) <> laden/web-67649cfddb-6d48k:80 (ID:44488) policy-verdict:none INGRESS DENIED (TCP Flags: SYN)
Nov 24 14:35:10.108: laden/werkbank:52646 (ID:1151) <> laden/web-67649cfddb-6d48k:80 (ID:44488) Policy denied DROPPED (TCP Flags: SYN)
NAME                   POD-SELECTOR    AGE
api-nur-von-web        app=api         73m
lieferung              app=lieferung   59m
standard-absicherung   tier=frontend   13s

A new policy on tier=frontend, i.e. web. It only allows traffic from a namespace ingress-nginx, which does not even exist in the lab: a “default protection” (standard-absicherung) from a template that does not fit this cluster. Deleting it would be treating the symptom. The intent (web reachable only from defined sources) is right; what is missing is the shop’s own namespace:

kubectl -n laden patch networkpolicy standard-absicherung --type=json -p '[{"op":"add","path":"/spec/ingress/0/from/-","value":{"podSelector":{}}}]'

Measurement:

kubectl -n laden exec werkbank -- wget -qO- -T3 http://web/ | grep -o "<title>.*</title>"
hubble observe --from-pod laden/werkbank --to-label app=web --type policy-verdict --last 1 -o compact

Expected:

<title>Welcome to nginx!</title>
Nov 24 14:35:26.479: laden/werkbank:53724 (ID:1151) -> laden/web-67649cfddb-6d48k:80 (ID:44488) policy-verdict:L3-Only INGRESS ALLOWED (TCP Flags: SYN)

podSelector: {} without namespaceSelector means: all Pods in the same namespace.

Save your progress? Sign up for free

Round 3: The Cache Is Gone

Referee:

kubectl apply -f ~/werkzeuge/tag09/cache-svc.yaml >/dev/null
clear

(If you have corrected the file from Day 9 in the meantime, this command changes nothing, and the round is won before it begins. That is exactly why you correct files.)

Symptom:

kubectl -n laden exec netshoot -- nc -zv -w2 cache 6379
nc: connect to cache (10.96.166.106) port 6379 (tcp) failed: Connection refused
command terminated with exit code 1

Hint: The name resolves, the connection is refused. Who is behind the Service? Day 9.

Solution Round 3

popeye -n laden -s svc -l error --force-exit-zero | grep -E "POP-|laden/"
kubectl -n laden get endpointslices -l kubernetes.io/service-name=cache

Expected (colors removed):

  · laden/cache....................................................................................💥
    💥 [POP-1100] No pods match service selector.
NAME          ADDRESSTYPE   PORTS     ENDPOINTS   AGE
cache-ptzv6   IPv4          <unset>   <unset>     69m

No endpoints, so Cilium rejects the connection to the Service IP immediately. The selector is app=redis again because someone applied the old file. The cause is the file, so the file gets fixed and applied, not just the cluster patched:

sed -i "s/selector: {app: redis}/selector: {app: cache}/" ~/werkzeuge/tag09/cache-svc.yaml
grep selector ~/werkzeuge/tag09/cache-svc.yaml
kubectl apply -f ~/werkzeuge/tag09/cache-svc.yaml

Measurement:

kubectl -n laden exec netshoot -- sh -c "printf 'PING\r\n' | nc -w2 cache 6379"

Expected:

+PONG

Save your progress? Sign up for free

Round 4: Something in the Warehouse Has Too Many Permissions

Referee:

kubectl create clusterrolebinding lager-monitoring --clusterrole=cluster-admin --serviceaccount=lager:default >/dev/null
clear

Symptom: The weekly Kubescape report has one more finding under “Administrative Roles” than last week.

kubescape scan control C-0035 --keep-local 2>/dev/null | grep -E "Administrative"
│  Medium  │ Administrative Roles │         3        │      102      │        97%       │

Hint: Who can read Secrets who could not yesterday? Day 11.

Solution Round 4

rbac-tool who-can get secrets | grep -E "lager|TYPE"
rbac-tool lookup -e "^default$"

Expected (columns shortened):

  TYPE           | SUBJECT                        | NAMESPACE
  ServiceAccount | default                        | lager
  SUBJECT | SUBJECT TYPE   | SCOPE       | NAMESPACE | ROLE          | BINDING
----------+----------------+-------------+-----------+---------------+-------------------
  default | ServiceAccount | ClusterRole |           | cluster-admin | lager-monitoring

The ServiceAccount default in lager is cluster-admin. The packer and inventur run under this account, and the packer has been privileged since Day 0: a break-in into the packer would thus mean the whole cluster. A name like lager-monitoring sounds harmless; that is why it pays to ask about the role, not the name. A monitoring binding that may do everything is a mistake, no matter who created it:

kubectl delete clusterrolebinding lager-monitoring

Measurement:

kubectl auth can-i get secrets -n kube-system --as=system:serviceaccount:lager:default

Expected:

no

Save your progress? Sign up for free

Round 5: Headlamp and the Audit

Referee:

helm upgrade headlamp headlamp/headlamp -n headlamp --version 0.46.0 --set replicaCount=2 >/dev/null
clear

Symptom: The team wanted two Headlamp replicas, and they are running. But:

kubectl get clusterrolebinding headlamp-admin
NAME             ROLE                        AGE
headlamp-admin   ClusterRole/cluster-admin   1s

Hint: What changed between the last two Helm revisions, and why? Day 12.

Solution Round 5

helm history headlamp -n headlamp --max 2
helm get values headlamp -n headlamp
helm get values headlamp -n headlamp --revision 4
helm diff revision headlamp 4 5 -n headlamp | grep -E "^headlamp,|^\+   name|^-   replicas|^\+   replicas"

Expected (revision numbers and times will differ):

REVISION    UPDATED                     STATUS      CHART           APP VERSION DESCRIPTION
4           Tue Nov 24 13:49:46 2026    superseded  headlamp-0.46.0 0.46.0      Rollback to 2
5           Tue Nov 24 14:36:23 2026    deployed    headlamp-0.46.0 0.46.0      Upgrade complete
USER-SUPPLIED VALUES:
replicaCount: 2
USER-SUPPLIED VALUES:
clusterRoleBinding:
  create: false
headlamp, headlamp, Deployment (apps) has changed:
-   replicas: 1
+   replicas: 2
headlamp, headlamp-admin, ClusterRoleBinding (rbac.authorization.k8s.io) has been added:
+   name: headlamp-admin
+   name: cluster-admin
+   name: headlamp
+   namespace: headlamp

The mistake from Drill 2 of Day 12: --set without --reuse-values forgot clusterRoleBinding.create=false. helm rollback would take the second replica away again, and --reuse-values would carry the broken state of revision 5 forward. The cause is that the values only exist in people’s heads and on command lines. So: one file, both values in it, the diff first:

cd ~/werkzeuge/tag15
printf "replicaCount: 2\nclusterRoleBinding:\n  create: false\n" > headlamp-values.yaml
cat headlamp-values.yaml
helm diff upgrade headlamp headlamp/headlamp -n headlamp --version 0.46.0 -f headlamp-values.yaml | grep -E "^headlamp,"
helm upgrade headlamp headlamp/headlamp -n headlamp --version 0.46.0 -f headlamp-values.yaml | grep REVISION

Expected:

replicaCount: 2
clusterRoleBinding:
  create: false
headlamp, headlamp-admin, ClusterRoleBinding (rbac.authorization.k8s.io) has been removed:
REVISION: 6

The diff shows exactly one change: the binding disappears, the replicas stay.

Measurement:

kubectl get clusterrolebinding headlamp-admin
kubectl -n headlamp get deploy headlamp -o jsonpath='{.status.readyReplicas}{"\n"}'

Expected:

Error from server (NotFound): clusterrolebindings.rbac.authorization.k8s.io "headlamp-admin" not found
2

Save your progress? Sign up for free

Scoring

After the last round, the same lines as at the beginning, plus the replicas:

echo "Kasse-Neustarts: $(kubectl -n laden get pods -l app=kasse -o jsonpath='{.items[*].status.containerStatuses[0].restartCount}')"
echo "Web: $(kubectl -n laden exec werkbank -- wget -qO- -T3 http://web/ | grep -o '<title>.*</title>')"
echo "Cache: $(kubectl -n laden exec netshoot -- sh -c "printf 'PING\r\n' | nc -w2 cache 6379" | tr -d '\r')"
echo "Lager liest kube-system-Secrets: $(kubectl auth can-i get secrets -n kube-system --as=system:serviceaccount:lager:default)"
echo "Headlamp-Admin-Bindung: $(kubectl get clusterrolebinding headlamp-admin --ignore-not-found -o name | wc -l)"
echo "Headlamp-Replikas: $(kubectl -n headlamp get deploy headlamp -o jsonpath={.status.readyReplicas})"

Expected:

Kasse-Neustarts: 0 0
Web: <title>Welcome to nginx!</title>
Cache: +PONG
Lager liest kube-system-Secrets: no
Headlamp-Admin-Bindung: 0
Headlamp-Replikas: 2
Points per round Condition
3 Cause fixed and proven with the measurement, within the target time
2 the same, up to twice the target time
1 fixed, but only with the hint
0 symptom fixed instead of cause (policy deleted, cluster patched instead of file, rollback with loss)

With 15 points, you have the right tool at hand for every situation. From 10 up, you know the tools; below that, it is worth repeating the days that belong to the lost rounds.

Challenge: the Lodger

Referee:

kubectl create ns keller >/dev/null
cat <<'EOF' | kubectl apply -f - >/dev/null
apiVersion: apps/v1
kind: Deployment
metadata:
  name: heizung
  namespace: keller
spec:
  selector:
    matchLabels: {app: heizung}
  template:
    metadata:
      labels: {app: heizung}
    spec:
      hostPID: true
      containers:
      - name: heizung
        image: busybox:1.37.0
        command: ["sleep", "infinity"]
        securityContext: {privileged: true}
        volumeMounts:
        - {name: wurzel, mountPath: /host}
      volumes:
      - name: wurzel
        hostPath: {path: /}
EOF
clear

Task: Somewhere in the cluster, a workload that can take over the node has just started running. You do not know in which namespace. Find it with one command, use a second tool to show why it is dangerous, and make sure that something like this is noticed in laden and lager in the future before it runs.

Solution

Search across all namespaces for the properties that endanger a node:

kubectl get pods -A -o json | jq -r '.items[] | select(any(.spec.containers[]; .securityContext.privileged==true) or .spec.hostPID==true) | [.metadata.namespace, .metadata.name, (.spec.hostPID // false)] | @tsv'

Expected (names will differ):

keller  heizung-644d4b6987-52hwh    true
kube-system kube-proxy-4dw4k    false
kube-system kube-proxy-t4qqv    false
kube-system kube-proxy-vqhhr    false
lager   packer-5867bb6b7d-g8gdf false

kube-proxy is privileged because it manages iptables on the node; the packer is the known case from Day 0. New is keller/heizung (basement/heating). Polaris against the cluster says why:

polaris audit --format pretty --only-show-failed-tests --severity danger | grep -A8 "in namespace keller"

Expected (shortened):

Deployment heizung in namespace keller
    hostPIDSet                           ❌ Danger
        Security - Host PID should not be configured
  Container heizung
    runAsPrivileged                      ❌ Danger
        Security - Should not be running as privileged
    privilegeEscalationAllowed           ❌ Danger
        Security - Privilege escalation should not be allowed
    runAsRootAllowed                     ❌ Danger

Privileged, with the node’s processes (hostPID) and its entire file system under /host (volume wurzel, root): one chroot /host inside it, and you are root on the node, as with kubectl debug node/… on Day 7. Get rid of it:

kubectl delete ns keller

And so that it gets noticed in the future: Pod Security Admission, built into Kubernetes. Before you enforce a level, you ask via dry run who would violate it today:

kubectl label --dry-run=server --overwrite ns laden lager pod-security.kubernetes.io/enforce=baseline

Expected:

Warning: existing pods in namespace "laden" violate the new PodSecurity enforce level "baseline:latest"
Warning: api-7d5f77c79b-725kc (and 1 other pod): non-default capabilities
namespace/laden labeled (server dry run)
Warning: existing pods in namespace "lager" violate the new PodSecurity enforce level "baseline:latest"
Warning: packer-5867bb6b7d-g8gdf: privileged
namespace/lager labeled (server dry run)

The packer is expected. Surprising is laden: api-…-725kc and a web Pod violate baseline because of capabilities. These are the ephemeral containers from Day 7 (debugger) and Day 8 (sniffer with --profile=netadmin) that are still in the Pods. Debug traces make a Pod less secure after the fact. Only after restarting these Pods (kubectl -n laden rollout restart deploy/api deploy/web) and an exception or solution for the packer can you switch enforce on; until then, warn instead of enforce reports violations without rejecting anything.

Save your progress? Sign up for free

Checkpoint

The scoring above is the checkpoint: six lines as expected, and keller no longer exists.

kubectl get ns keller --ignore-not-found --no-headers | wc -l

Expected:

0

Clean-up

The lab stays in place for the appendices. If you want to tear it down completely:

kind delete cluster --name werkzeuge

That removes the cluster, the context and all data; the tools in /usr/local/bin, ~/.krew and ~/.local/bin remain on the VM.

Practice Note

  • The five rounds are the most common incidents in real clusters: missing configuration after a patch, a policy from a template, an outdated file, a binding with too many permissions, a Helm upgrade with forgotten values. None of them needs an exotic tool, but each gets faster when you know which one.
  • Three rounds had the same root: the state in the cluster and the state in files had drifted apart. Whoever consistently rolls out manifests and values from Git (Day 12) never loses these rounds in the first place.
  • The tools from this course do not replace monitoring. They are for the moment when someone says: “Something is wrong.”

Contents

More