kube-bench run --parallel
7. 更新CIS基准到最新版本
kube-bench download latest
8. 查看kube-bench版本
kube-bench version
kube-bench配置
1.文件格式
kube-bench的配置文件采用YAML格式,包含一系列的检查项配置。每个检查项通过唯一的id进行标识。
测试项目配置文件路径:/etc/kube-bench/cfg/cis-1.6/
配置项示例:
- id: 1.2.21
text: “Ensure that the --profiling argument is set to false (Automated)”
audit: “/bin/ps -ef | grep $apiserverpbin | grep -v grep”
tests:
test_items:
- flag: “–profiling”
compare:
op: eq
value: false
remediation: |
Edit the API server pod specification file $apiservercconf
on the master node and set the below parameter.
–profiling=fals
2.检查项字段
每个检查项都包含以下几个主要字段:
id: 唯一标识符
text: 对该检查项的文字描述
audit: 执行审计的命令,用于检查当前系统状态
tests: 具体的测试条件 #tests下的test_items字段定义了具体的测试条件。可以根据实际需求修改该部分的测试逻辑
- test_items: 实际测试项
- compare: 测试结果与期望值的比较方式(eq、neq等)
remediation: 如果审计失败,给出的修复建议
scored: 该项对总分数的影响(true、false、WARN)
type: 该项的处理方式(manual、skip、info) #对于某些无法自动检查的项目,可以设置type=manual,kube-bench就会跳过该项并给出WARN警告。如果想跳过某项检查,可以将对应项的type设为skip,这样kube-bench就不会执行该项检查。
- 处理