This challenge checks that you can, on your own, harden the control plane of a kubeadm cluster: fix the findings that the CIS audit holds against its components, then give the API server an audit policy. It is meant for people who have just followed the lessons CIS Kubernetes Benchmark and Kubernetes Audit Logs. It runs in a dsoxlab virtual machine, on a kubeadm cluster with Kubernetes 1.37, and takes about 50 minutes. It gives no hints and teaches nothing new: it checks what the lessons and their guided labs have already let you practice.
What you will learn
The lab reads the manifests on the node, runs kube-bench itself again, reads a Secret and an ordinary resource, then reads back the log the API server has just written. It checks that you can:
- Harden the API server: turn off its profiler, make it check the service account tokens it receives and set a minimum TLS version, without stopping it from answering.
- Fix, on three control plane components, the same finding reported by the CIS audit.
- Run kube-bench again to check that the number of failures goes down.
- Write an audit policy with two levels, detailed for Secrets and reduced to metadata for everything else.
- Enable that policy on the API server and check what it writes in its log.
What should you be able to do before you start?
No step-by-step guide goes with the challenge, and choosing the right settings is part of what it checks. Everything it asks for is taught in the following lessons:
- Kubernetes Audit Logs: write an audit policy, enable it on the API server and read the log.
- CIS Kubernetes Benchmark: run kube-bench, read its checks and fix the findings.
- Secure a Kubernetes cluster: control plane hardening seen as a whole.
- Protecting the Secrets of a Kubernetes cluster: what can be read or recorded of a Secret.
If one of these points feels unclear, reread the lesson before you start.
What does the statement ask for?
The kubeadm cluster comes out of a default install. The compliance team ran a CIS audit on it and wants two things before the next review: the findings that can be fixed without changing the architecture are fixed, and the cluster keeps a trace of who reads its Secrets.
Today, the API server exposes its Go profiler, nothing is audited, and the control plane carries the settings kubeadm writes by default. The kube-bench Job is written on the node, in /root/kube-bench-job.yaml, and runs in the conformite namespace. That namespace also holds the Secret jeton-de-paiement, the one the compliance team wants to see traced. The audit has already been run once and its failure count has been kept. You are on the control plane, with kubectl and sudo.
The statement says what must be true at the end, never how to get there:
- The API server runs with its profiler off, checks that a presented service account token still exists, and refuses TLS versions below a floor you set.
- The profiler at
/debug/pprof/no longer answers, and the API server still answers ordinary requests. - The finding the CIS audit holds against the API server, the controller manager and the scheduler, checks 1.2.15, 1.3.2 and 1.4.1, is fixed on all three.
- kube-bench, run again, passes those three checks and counts fewer failures than at the start. This requirement is blocking.
- An audit policy in
/etc/kubernetes/audit-policy.yamlrecords accesses to Secrets in full, request and response, and everything else as metadata only. - The API server runs with that audit: it reads that policy and writes its log to
/var/log/kubernetes/audit.logon the node, and it still answers. - The log actually holds the trace of a Secret read, in full, and that of an ordinary read, as metadata only. This requirement is blocking.
How do you start the challenge and get graded?
The lab prepares the cluster and the kube-bench Job, then reads the state of the control plane when you ask for the grade. You start it with dsoxlab run k8s-challenge-durcir-le-plan-de-controle. Two commands are then used: dsoxlab check k8s-challenge-durcir-le-plan-de-controle tells you where you stand, criterion by criterion, as many times as you like, and dsoxlab submit k8s-challenge-durcir-le-plan-de-controle returns the final result. The lab never looks at the commands you typed: it reads the manifests on the node, runs kube-bench again and compares its count with the starting one, reads a Secret and an ordinary resource, then reads back what the API server has just written.
Put it into practice
This lab is the challenge itself. It puts you in front of the situation described above and it is graded on the state of the control plane, as a colleague taking over your work would do.
How is the challenge graded?
The pass mark is 70 points out of 100. Seven requirements of equal weight make up the grade, in the order of the statement. Requirements 4 and 7 are blocking: if one of the two is not met, the challenge fails, whatever the total.
If a criterion resists, dsoxlab check gives its label without saying how to fix it. Reread the lesson that covers its subject, CIS Kubernetes Benchmark or Kubernetes Audit Logs, fix it, then run dsoxlab check again.
Key points
- The challenge is a final exercise to do alone and without hints: it explains nothing and grades the state of the control plane, not your commands.
- Requirements 4 and 7 are blocking: kube-bench run again with fewer failures, and an audit log that holds the trace of both reads.
- The starting failure count is kept: the lab runs kube-bench again and compares, it does not read a report you would have produced.
dsoxlab checklists the criteria that are not met;dsoxlab submitreturns the result.