Hardening with CIS Benchmarks
Introduction to CIS Benchmarks
The Center for Internet Security (CIS) provides best practices for securing Kubernetes. In this lab, we will use kube-bench, an open-source tool from Aqua Security, to check whether our cluster meets these security recommendations.
Manual Installation and Discovery
First, let’s explore the CIS rules by installing the tool directly on a control-plane node.
Connect to your control-plane node and download the latest binary:
Run a scan for the control plane:
Analyze the output. What are the three possible statuses for a check?
Running kube-bench as a Job
In a CKS exam or production environment, you often run kube-bench as a Kubernetes Job to scan nodes without SSH access.
Create a file named kube-bench-job.yaml:
Apply the job and check the logs:
Remediation Practice
Look for the check 1.2.20: Ensure that the –profiling argument is set to false.
- Check the current status of the API Server:
- Fix the issue by editing the static pod manifest on the control plane node:
Add the line --profiling=false under the command section.
Note
Wait for the API Server to restart automatically. If you make a syntax error in the YAML file, the API Server will disappear from kubectl get pods and you will need to fix it directly on the node’s disk.
- Run
kube-benchagain. Is the check passing now?
Automation and Continuous Compliance
Why is running kube-bench manually not enough for a production environment?
Suggested improvement
Integrate kube-bench into a CronJob to run every week and send results to a security dashboard like Falco or a SIEM.
Congratulations! You now know how to audit a cluster against industry standards and perform basic hardening 🛡️!
Would you like me to generate a specific remediation guide for Kubelet security settings (Section 4 of the CIS Benchmark)?