了解什么是CIS基准
Center for Internet Security
Internet 安全中心是一个非盈利性实体,其任务是“确定、开发、验证、升级和维持针对网
络防御的最佳做法解决方案”。 它借鉴了来自世界各地政府、企业和学术界网络安全及 IT
专业人员的专业知识。 为了制定标准和最佳做法(包括 CIS 基准、控制措施和强化映像),
他们遵循一致的决策制定模型。
CIS 基准提供两个级别的安全设置:
L1(即级别 1)建议可在任何系统上配置且应基本不会或不会导致服务中断或导致功能性降低的基
本必需安全要求。
L2(即级别 2)建议适用于需高安全性的环境,但可能会导致某些功能性降低的安全设置。
https://www.cisecurity.org/benchmark/kubernetes/
使用kube-bench检测系统安全
安装kube-bench
检测master
检测kubelet
https://github.com/aquasecurity/kube-bench/tags
./kube-bench --config-dir `pwd`/cfg --config `pwd`/cfg/config.yaml run --targets=etcd
master node controlplane etcd policies
旧版本
kube-bench master
kube-bench node
etcd是一个服务发现系统,具备以下的特点:
简单:安装配置简单,而且提供了HTTP API进行交互,使用也很简单
安全:支持SSL证书验证
快速:根据官方提供的benchmark数据,单实例支持每秒2k+读操作
可靠:采用raft算法,实现分布式系统数据的可用性和一致性
etcd应用场景
用于服务发现,服务发现(ServiceDiscovery)要解决的是分布式系统中最常见的问题之一,即在同一个分布式集群中的进程或服务如何才能找到对方并建立连接。
要解决服务发现的问题,需要具备下面三种必备属性。
1.AlwaysDeny
表示拒绝所有请求,通常不使用哈
2.AlwaysAllow
默认的策略,允许接收所有请求,就相当于没进行权限控制
3.ABAC
表示使用用户配置的授权规则对用户请求进行匹配和控制(基于用户属性)
4.Webhook
引用外部REST服务对用户进行授权管理
5.Node
用于对kubelet发出的请求进行访问控制,比较特殊的一种模式
6.RBAC
基于角色访问控制,一般是需要账号等
1-kubebench
开始检测
1-安装kube-bench
tar zxf kube-bench_0.6.3_linux_amd64.tar.gz
监测master
./kube-bench --config-dir cfg --config cfg/config.yaml run --targets=master
模拟问题1
vim /etc/kubernetes/manifests/kube-apiserver.yaml
注释- --authorization-mode=Node,RBAC
再次添加- --authorization-mode=AlwaysAllow
vim /etc/kubernetes/manifests/etcd.yaml
改参数把true改为false
- --client-cert-auth=false
重启kubelet
systemctl restart kubelet
模拟问题2
vim /var/lib/kubelet/config.yaml
authentication:
anonymous:
enabled: false ---> true
authorization:
mode: Webhook ---> AlwaysAllow
重启kubelet
systemctl restart kubelet
根据提示修改。