Kubernetes Security (CKS)
Harden a cluster the way the CKS exam and a security review expect: audit logs, encrypted Secrets, the CIS benchmark, scanned and signed images enforced at admission, and runtime detection with Falco.
In plain words
Chapter 19 put good locks on every room of the house. This chapter is about the rest of the building: a camera on the front door (the audit log), a safe for the valuables (encryption at rest), a building inspector with a checklist (kube-bench), a guard who checks every delivery (scanning, signing and admission policies), sealed rooms for strangers (gVisor) and a motion sensor inside (Falco) for when someone gets in anyway.
Why it matters on call
Platform and SRE teams own the cluster, not only the apps that run on it. Security reviews, the CKS exam and real incidents all ask the same questions: who did what, are Secrets readable at rest, which control plane flags are unsafe, which images may run, how far can a broken container reach, and how would you notice an attacker who is already inside. Each lesson answers one of those questions with the real tool and a lab where you prove the answer.
Lessons
- 23.1The CKS map: what a cluster attacker goes after
- 23.2Audit logging: who did what to the API
- 23.4Encryption at rest: Secrets in etcd
- 23.7Verify a Kubernetes binary before you trust it
- 23.9Keep pods away from the node's cloud credentials
- 23.11A firewall on the nodes: what a kubeadm node must accept, and what ufw cannot see
- 23.13kube-bench: the CIS benchmark as a checklist
- 23.15AppArmor: confine what a container may touch
- 23.17seccomp: allow-list the system calls
- 23.19Sandboxed containers: RuntimeClass and gVisor
- 23.21Supply chain: scan, sign, and enforce at admission
- 23.23Static analysis: kubesec and kube-linter before you apply
- 23.25ValidatingAdmissionPolicy: admission rules in CEL, built in
- 23.27Kyverno 1.19: validate, mutate, and read the PolicyReports
- 23.31Runtime detection with Falco
- 23.34The CKS exam: how the tasks run, and the drills
Open this chapter in the terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.
Questions people ask
Do I need chapter 19 and the CKA chapter first?
Yes. This chapter assumes Pod Security, RBAC and securityContext from chapter 19, and the control plane as static pods on cp-1 from chapter 20. The CKS exam itself requires that you have passed the CKA first.
Which tools are simulated?
Audit logging, encryption at rest with etcdctl, kube-bench with the CIS 1.10 master checks, AppArmor and seccomp profiles on the nodes, RuntimeClass with gVisor, sha256sum --check, trivy and syft with a small lab database, cosign, Kyverno verifyImages, ValidatingAdmissionPolicy with a CEL subset, the metadata endpoint and two Falco rules.
Is the exam the same as these labs?
The tasks are the same kind: edit a manifest or a node file, apply a policy, then prove that it works. The exam adds time pressure and real clusters, and it may ask about topics this first version of the chapter only touches, so read the current curriculum before you book.
Why are there so many control plane edits?
Because the control plane runs as static pods: changing a flag means editing /etc/kubernetes/manifests/*.yaml on the control plane node, and the kubelet restarts that component on its own. Most CKS cluster tasks look exactly like that, so practising the edit matters.
What is the most common mistake?
Forgetting the mounts. The apiserver runs in a container, so a flag that points at a policy or config file only works when that file is also mounted into the container with a hostPath volume. Without the mount the component cannot read the file at all.