Hardening with CIS Benchmarks - Security Remediations
Author: Fabrice JAMMES (LinkedIn).
Objective
Fix failed checks of the kube-bench report by editing the static pod manifests of the control plane, then check the fix with a new scan. It is the typical CKS task: “fix the issues reported by kube-bench on the control plane”.
Prerequisites
The control plane components restart during the lab: use a kind cluster of your own, never a shared one.
The Job of the previous lab, which scans the control plane, and a function which runs it again and displays the result of some checks:
Exercise 1: the profiling of the scheduler
Check 1.4.1: the scheduler serves profiling data (/debug/pprof), which shows details on the internals of the cluster and can be used to overload it.
- Which is the default value of
--profilingfor the scheduler? Is the flag set in its manifest? - Set
--profiling=falsein the manifest of the scheduler, on the control plane node. Save a copy of the manifest first, outside/etc/kubernetes/manifests. - Scan again.
Warning
Very important for the CKS exam: save a copy of the manifest outside /etc/kubernetes/manifests, e.g. in /root. The kubelet runs every file of this directory as a static pod: a backup copy there would start a second scheduler.
Exercise 2: the controller manager
Fix the check 1.3.2 alone: the same flag, for the controller manager.
Questions
- Why save the copy of a manifest outside
/etc/kubernetes/manifests? - The fix of a kubelet check (target
node) is in which file?
Clean up
Next: Hardening with CIS Benchmarks - Automation and Continuous Compliance.