CIS安全介绍
互联网安全中心(CIS,Center for Internet Security),是一个非盈利组织,致力为互联网提供免费的安全防御解决方案。
官网:https://www.cisecurity.org/
Kubernetes CIS基准:https://www.cisecurity.org/benchmark/kubernetes/
在这里插入图片描述

在这里插入图片描述
使用CIS基准测试工具
在如上图下载pdf说明后。可参考基本标准对集群配置进行检查,内容较多,一般会会采用相关工具kube-bench来完成这项工作。
Kube-bench是容器安全厂商Aquq推出的工具,以CIS K8s基准作为基础,来检查K8s是否安全部署。主要查找不安全的配置参数、敏感的文件权限、不安全的帐户或公开端口等等。
安装使用:
安装包下载
https://github.com/aquasecurity/kube-bench/releases
注:官方更新后会发布到github在这里下载更新即可、官方有其他使用方式说明具体参考官方hub

[root@master1 ~]# tar zxvf kube-bench_0.6.3_linux_amd64.tar.gz
[root@master1 ~]# mkdir /etc/kube-bench
[root@master1 ~]# mv cfg /etc/kube-bench/cfg
[root@master1 ~]# ./kube-bench --help     #安装完成 help帮助查看使用方法
[root@master1 ~]# mv kube-bench /usr/bin/

使用kube-bench run进行测试,该指令有以下常用参数:
常用参数:
• -s, --targets 指定要基础测试的目标,这个目标需要匹配cfg/中的文件名称,已有目标:master, controlplane, node,etcd, policies
• --version:指定k8s版本,如果未指定会自动检测
• --benchmark:手动指定CIS基准版本,不能与–version一起使用

#检查master组件安全配置
[root@master1 ~]# kube-bench run --targets=master
[INFO] 1 Master Node Security Configuration
[INFO] 1.1 Master Node Configuration Files
[PASS] 1.1.1 Ensure that the API server pod specification file permissions are set to 644 or more restrictive (Automated)
[PASS] 1.1.2 Ensure that the API server pod specification file ownership is set to root:root (Automated)
[PASS] 1.1.3 Ensure that the controller manager pod specification file permissions are set to 644 or more restrictive (Automated)
[PASS] 1.1.4 Ensure that the controller manager pod specification file ownership is set to root:root (Automated)
[PASS] 1.1.5 Ensure that the scheduler pod specification file permissions are set to 644 or more restrictive (Automated)
[PASS] 1.1.6 Ensure that the scheduler pod specification file ownership is set to root:root (Automated)
[PASS] 1.1.7 Ensure that the etcd pod specification file permissions are set to 644 or more restrictive (Automated)

执行后会逐个检查安全配置并输出修复方案及汇总信息输出:

== Summary master ==
44 checks PASS
10 checks FAIL
11 checks WARN
0 checks INFO

== Summary total ==
44 checks PASS
10 checks FAIL
11 checks WARN
0 checks INFO

参数说明

[PASS]:测试通过
[FAIL]:测试未通过,重点关注,在测试结果会给出修复建议
[WARN]:警告,可做了解
[INFO]:信息

kube-bench的配置文件

[root@master1 ~]# cd /etc/kube-bench/
[root@master1 kube-bench]# ls
cfg
[root@master1 kube-bench]# cd cfg
[root@master1 cfg]# ls
ack-1.0  cis-1.5  config.yaml  gke-1.0  rh-1.0
aks-1.0  cis-1.6  eks-1.0      rh-0.7
[root@master1 cfg]# cd cis-1.6/
[root@master1 cis-1.6]# ls
config.yaml        etcd.yaml    node.yaml
controlplane.yaml  master.yaml  policies.yaml

注:这是扫描用的基准配置文件
如果有发现误报修改配置文件进行跳过
参考:

• id:编号
• text:提示的文本
• audit:
• tests:测试项目
• remediation:修复方案
• scored:如果为true,kube-bench无法正常测试,则会生成FAIL,如果为false,无法正常测试,则会生成WARN。
• type:如果为manual则会生成WARN,如果为skip,则会生成INFO

在这里插入图片描述
适用于二进制、admin、云上环境

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐