【云原生-K8s】Kubernetes安全组件CIS基准kube-beach安装及使用
温馨提示:这篇文章已超过386天没有更新,请注意相关的内容是否还可用!
- 基础介绍
- kube-beach介绍
- kube-beach 下载
- 百度网盘下载
- wget下载
- kube-beach安装
- kube-beach使用
- 基础参数
- 配置信息解读
- 示例
- 修复建议
- 修复一个安全漏洞【1.2.18】
- 结果说明
- kube-beach跳过漏洞
- 漏洞定义
- 漏洞定义yaml说明
- 漏洞生成为INFO
基础介绍
- 为了保证集群以及容器应用的安全,Kubernetes 提供了多种安全机制,限制容器的行为,减少容器和集群的攻击面,保证整个系统的安全性。
- 互联网安全中心(CIS,Center for Internet Security),是一个非盈利组织,致力为互联网提供免费的安全防御解决方案
- 官网:https://www.cisecurity.org/
- k8s安全基准:https://www.cisecurity.org/benchmark/kubernetes
kube-beach介绍
- Kube-bench是容器安全厂商Aquq推出的工具,以CIS K8s基准作为基础,来检查K8s是否安全部署。
- 主要查找不安全的配置参数、敏感的文件权限、不安全的帐户或公开端口等等。
- 开源地址:https://github.com/aquasecurity/kube-bench
- 二进制包下载地址:https://github.com/aquasecurity/kube-bench/releases
- 大家根据需求下载相应版本
kube-beach 下载
百度网盘下载
链接:https://pan.baidu.com/s/17AGxkwTDUkiDYSSZpPu45A?pwd=vqew
提取码:vqew
–来自百度网盘超级会员V7的分享
wget下载
wget https://github.com/aquasecurity/kube-bench/releases/download/v0.6.19/kube-bench_0.6.19_linux_amd64.tar.gz
kube-beach安装
- 解压
tar -zxf kube-bench_0.6.19_linux_amd64.tar.gz
- 创建默认配置路径
mkdir -p /etc/kube-bench
- 复制配置文件至默认目录
mv cfg /etc/kube-bench/cfg
- 设置为系统命令
mv kube-bench /usr/bin/
kube-beach使用
基础参数
-
使用kube-bench run进行测试,该指令有以下常用参数
-
–targets 指定要基础测试的目标,默认配置目标包括:master, controlplane, node, etcd, policies
-
–version:指定k8s版本,如果未指定会自动检测
-
–benchmark:手动指定CIS基准版本,不能与–version一起使用
-
查看帮助信息
kube-bench --help
配置信息解读
- 在该目录下 /etc/kube-bench/cfg
- 该版本默认使用 cis-1.7
- 也支持其他 云厂商的验证基准 【ack-1.0 容器服务 Kubernetes 版 ACK】
示例
- 检查master组件安全配置
kube-bench run --targets=master
修复建议
修复一个安全漏洞【1.2.18】
- 安全漏洞
[FAIL] 1.2.18 Ensure that the --profiling argument is set to false (Automated)
- 修复建议
1.2.18 Edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml on the control plane node and set the below parameter. --profiling=false
- 编辑 kube-apiserver.yaml ,增加 --profiling=false
- 修改完后 kube-apiserver 静态pod进行重启
- 已通过安全扫描
结果说明
- [PASS]:测试通过
- [FAIL]:测试未通过,重点关注,在测试结果会给出修复建议
- [WARN]:警告,可做了解
- [INFO]:信息
- 大家可以根据实际情况,推荐的修复方案进行实际的修复措施。
kube-beach跳过漏洞
- kube-beach 所有扫描出来的漏洞不一定需要全部修复,如果需要跳过我们需要修改kube-beach的漏洞定义配置文件
漏洞定义
[FAIL] 1.4.1 Ensure that the --profiling argument is set to false (Automated)
- 在 /etc/kube-bench/cfg/cis-1.23【具体k8s版本】 目录编辑 master.yaml
- 找到 1.4.1 配置信息
- id: 1.4.1 text: "Ensure that the --profiling argument is set to false (Automated)" audit: "/bin/ps -ef | grep $schedulerbin | grep -v grep" tests: test_items: - flag: "--profiling" compare: op: eq value: false remediation: | Edit the Scheduler pod specification file $schedulerconf file on the control plane node and set the below parameter. --profiling=false scored: true漏洞定义yaml说明
- id:编号
- text:提示的文本
- tests:测试项目
- remediation:修复方案
- scored:如果为true,kube-bench无法正常测试,则会生成FAIL,如果为false,无法正常测试,则会生成WARN。
- type:如果为manual则会生成WARN,如果为skip,则会生成INFO
漏洞生成为INFO
- 修改后的yaml
- id: 1.4.1 text: "Ensure zhangzihao that the --profiling argument is set to false (Automated)" audit: "/bin/ps -ef | grep $schedulerbin | grep -v grep" tests: test_items: - flag: "--profiling" compare: op: eq value: false remediation: | Edit the Scheduler pod specification file $schedulerconf file on the control plane node and set the below parameter. --profiling=false scored: true type: "skip"
- 修改后的yaml
- kube-beach 所有扫描出来的漏洞不一定需要全部修复,如果需要跳过我们需要修改kube-beach的漏洞定义配置文件
- 修复建议
- 安全漏洞
- 检查master组件安全配置
-
- 设置为系统命令
- 复制配置文件至默认目录
- 创建默认配置路径
- 解压
免责声明:我们致力于保护作者版权,注重分享,被刊用文章因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理! 部分文章是来自自研大数据AI进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理! 图片声明:本站部分配图来自人工智能系统AI生成,觅知网授权图片,PxHere摄影无版权图库和百度,360,搜狗等多加搜索引擎自动关键词搜索配图,如有侵权的图片,请第一时间联系我们,邮箱:ciyunidc@ciyunshuju.com。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!










