kube-bench
CIS Benchmarking with kube-bench
1. Overview
git clone https://github.com/aquasecurity/kube-bench.git
cd kube-bench # Navigate into the cloned directory to find the YAML files2. Running kube-bench as a Job
kube-bench as a Job2.1 Inspecting job.yaml
job.yaml---
apiVersion: batch/v1
kind: Job
metadata:
name: kube-bench
spec:
template:
metadata:
labels:
app: kube-bench
spec:
hostPID: true
containers:
- name: kube-bench
image: aquasec/kube-bench:latest
# Note: For repeatable scans, consider using a specific version tag
# instead of :latest, e.g., aquasec/kube-bench:v0.X.Y
command: ["kube-bench"] # You can add arguments here, e.g., ["kube-bench", "master"]
volumeMounts:
- name: var-lib-etcd
mountPath: /var/lib/etcd
readOnly: true
- name: var-lib-kubelet
mountPath: /var/lib/kubelet
readOnly: true
- name: etc-systemd
mountPath: /etc/systemd
readOnly: true
- name: etc-kubernetes
mountPath: /etc/kubernetes
readOnly: true
# /usr/local/mount-from-host/bin is mounted to access kubectl / kubelet,
# for auto-detecting the Kubernetes version.
# You can omit this mount if you specify --version as part of the command.
- name: usr-bin
mountPath: /usr/local/mount-from-host/bin # Path inside container
readOnly: true
restartPolicy: Never
volumes:
- name: var-lib-etcd
hostPath:
path: "/var/lib/etcd"
- name: var-lib-kubelet
hostPath:
path: "/var/lib/kubelet"
- name: etc-systemd
hostPath:
path: "/etc/systemd"
- name: etc-kubernetes
hostPath:
path: "/etc/kubernetes"
- name: usr-bin
hostPath:
path: "/usr/bin" # Path on the host2.2 Starting the Benchmark
2.3 Monitoring the Job and Pods
2.4 Retrieving Results
3. Alternative: Running Node-Specific Jobs
Last updated