本文档介绍了 CIS Kubernetes 基准、如何审核基准合规性,以及您在无法自行实施建议时 Google Distributed Cloud (GDC) air-gapped 配置的内容。
CIS 基准简介
Center for Internet Security(CIS,互联网安全中心)公布了最佳做法安全建议的基准。CIS Kubernetes 基准提供了一系列用于配置 Kubernetes 以支持可靠的安全状况的建议。基准与特定的 Kubernetes 版本相关联。CIS Kubernetes 基准是针对开源 Kubernetes 发行版编写的,旨在尽可能广泛应用于各个发行版。
访问基准
您可以通过 CIS 网站获取 CIS Kubernetes 基准。
建议级别
下表介绍了 CIS Kubernetes 基准中的建议级别。
| 级别 | 说明 |
|---|---|
| 1 级 | 建议具有以下一个或多个特性: |
| 2 级 | 扩展第 1 级配置文件。 建议具有以下一个或多个特性: |
评估状态
每项建议都会包含评估状态。评估状态表明给定建议可以自动执行,还是需要手动步骤来实施。这两种状态同样重要,并根据下表的定义进行确定和提供支持。
版本
本评估涉及以下版本:
| 裸金属上的 GDC 版本 | Kubernetes 版本 | CIS Kubernetes 基准版本 |
|---|---|---|
| 1.30 | 1.30.9 | v0.10.4 |
GDC 气隙 Kubernetes 集群的状态
| # | 建议 | 级别 | 状态 |
|---|---|---|---|
| 1 | 控制平面安全配置 | ||
| 1.1 | 控制平面节点配置文件 | ||
| 1.1.1 | 确保将 API 服务器 pod 规范文件权限设置为 600 或更严格(自动) |
L1 | 通过 |
| 1.1.2 | 确保将 API 服务器 pod 规范文件所有权设置为 root:root(自动) |
L1 | 通过 |
| 1.1.3 | 确保控制器管理器 pod 规范文件权限设置为 600 或更严格(自动) |
L1 | 通过 |
| 1.1.4 | 确保控制器管理器 pod 规范文件所有权设置为 root:root(自动) |
L1 | 通过 |
| 1.1.5 | 确保将调度器 pod 规范文件权限设置为 600 或更严格(自动) |
L1 | 通过 |
| 1.1.6 | 确保将调度器 pod 规范文件所有权设置为 root:root(自动) |
L1 | 通过 |
| 1.1.7 | 确保将 etcd pod 规范文件权限设置为 600 或更严格(自动) |
L1 | 通过 |
| 1.1.8 | 确保将 etcd pod 规范文件所有权设置为 root:root(自动) |
L1 | 通过 |
| 1.1.9 | 确保将容器网络接口文件权限设置为 600 或更严格(手动) |
L1 | 警告 |
| 1.1.10 | 确保将容器网络接口文件所有权设置为 root:root(手动) |
L1 | 警告 |
| 1.1.11 | 确保将 etcd 数据目录权限设置为 700 或更严格(自动) |
L1 | 通过 |
| 1.1.12 | 确保将 etcd 数据目录所有权设置为 etcd:etcd(自动) |
L1 | 失败 |
| 1.1.13 | 确保将默认管理凭据文件权限设置为 600(自动) |
L1 | 通过 |
| 1.1.14 | 确保将默认管理凭据文件所有权设置为 root:root(自动) |
L1 | 通过 |
| 1.1.15 | 确保将 scheduler.conf 文件权限设置为 600 或更严格(自动) |
L1 | 通过 |
| 1.1.16 | 确保将 scheduler.conf 文件所有权设置为 root:root(自动) |
L1 | 失败 |
| 1.1.17 | 确保将 controller-manager.conf 文件权限设置为 600 或更严格(自动) |
L1 | 通过 |
| 1.1.18 | 确保将 controller-manager.conf 文件所有权设置为 root:root(自动) |
L1 | 失败 |
| 1.1.19 | 确保将 Kubernetes PKI 目录和文件所有权设置为 root:root(自动) |
L1 | 失败 |
| 1.1.20 | 确保将 Kubernetes PKI 证书文件权限设置为 600 或更严格(手动) |
L1 | 警告 |
| 1.1.21 | 确保将 Kubernetes PKI 密钥文件权限设置为 600(手动) |
L1 | 警告 |
| 1.2 | API 服务器 | ||
| 1.2.1 | 确保将 --anonymous-auth 参数设置为 false(手动) |
L1 | 警告 |
| 1.2.2 | 确保未设置 --token-auth-file 参数(自动) |
L1 | 通过 |
| 1.2.3 | 确保已设置 --DenyServiceExternalIPs(手动) |
L1 | 警告 |
| 1.2.4 | 确保对 --kubelet-client-certificate 和 --kubelet-client-key 参数进行适当设置(自动) |
L1 | 通过 |
| 1.2.5 | 确保对 --kubelet-certificate-authority 参数进行适当设置(自动) |
L1 | 通过 |
| 1.2.6 | 确保 --authorization-mode 参数未设置为 AlwaysAllow(自动) |
L1 | 通过 |
| 1.2.7 | 确保 --authorization-mode 参数包含 Node(自动) |
L1 | 通过 |
| 1.2.8 | 确保 --authorization-mode 参数包含 RBAC(自动) |
L1 | 通过 |
| 1.2.9 | 确保已设置准许控制插件 EventRateLimit(手动) |
L1 | 警告 |
| 1.2.10 | 确保未设置准许控制插件 AlwaysAdmit(自动) |
L1 | 通过 |
| 1.2.11 | 确保已设置准许控制插件 AlwaysPullImages(手动) |
L1 | 警告 |
| 1.2.12 | 确保已设置准许控制插件 ServiceAccount(自动) |
L1 | 通过 |
| 1.2.13 | 确保已设置准许控制插件 NamespaceLifecycle(自动) |
L1 | 通过 |
| 1.2.14 | 确保已设置准许控制插件 NodeRestriction(自动) |
L1 | 通过 |
| 1.2.15 | 确保将 --profiling 参数设置为 false(自动) |
L1 | 通过 |
| 1.2.16 | 确保设置 --audit-log-path 参数(自动) |
L1 | 通过 |
| 1.2.17 | 确保将 --audit-log-maxage 参数设置为 30 或进行适当设置(自动) |
L1 | 通过 |
| 1.2.18 | 确保将 --audit-log-maxbackup 参数设置为 10 或进行适当设置(自动) |
L1 | 通过 |
| 1.2.19 | 确保将 --audit-log-maxsize 参数设置为 100 或进行适当设置(自动) |
L1 | 通过 |
| 1.2.20 | 确保对 --request-timeout 参数进行适当设置(手动) |
L1 | 警告 |
| 1.2.21 | 确保将 --service-account-lookup 参数设置为 true(自动) |
L1 | 通过 |
| 1.2.22 | 确保对 --service-account-key-file 参数进行适当设置(自动) |
L1 | 通过 |
| 1.2.23 | 确保对 --etcd-certfile 和 --etcd-keyfile 参数进行适当设置(自动) |
L1 | 通过 |
| 1.2.24 | 确保对 --tls-cert-file 和 --tls-private-key-file 参数进行适当设置(自动) |
L1 | 通过 |
| 1.2.25 | 确保对 --client-ca-file 参数进行适当设置(自动) |
L1 | 通过 |
| 1.2.26 | 确保对 --etcd-cafile 参数进行适当设置(自动) |
L1 | 通过 |
| 1.2.27 | 确保对 --encryption-provider-config 参数进行适当设置(手动) |
L1 | 通过 |
| 1.2.28 | 确保正确配置加密提供程序(手动) | L1 | 通过 |
| 1.2.29 | 确保 API 服务器仅使用强加密加密方式(手动) | L1 | 通过 |
| 1.3 | 控制器管理器 | ||
| 1.3.1 | 确保对 --terminated-pod-gc-threshold 参数进行适当设置(手动) |
L1 | 通过 |
| 1.3.2 | 确保将 --profiling argument 设置为 false(自动) |
L1 | 通过 |
| 1.3.3 | 确保将 --use-service-account-credentials 参数设置为 true(自动) |
L1 | 通过 |
| 1.3.4 | 确保对 --service-account-private-key-file 参数进行适当设置(自动) |
L1 | 通过 |
| 1.3.5 | 确保对 --root-ca-file 参数进行适当设置(自动) |
L1 | 通过 |
| 1.3.6 | 确保将 RotateKubeletServerCertificate 参数设置为 true(自动) |
L2 | 通过 |
| 1.3.7 | 确保将 --bind-address 参数设置为 127.0.0.1(自动) |
L1 | 失败 |
| 1.4 | 调度器 | ||
| 1.4.1 | 确保将 --profiling 参数设置为 false(自动) |
L1 | 通过 |
| 1.4.2 | 确保将 --bind-address 参数设置为 127.0.0.1(自动) |
L1 | 失败 |
审核基准
如需详细了解如何审核每项建议,请参阅相关的 CIS 基准。不过,您可能需要自动执行其中某些检查,以简化您的环境中这些控制措施的验证过程。以下工具可以帮助您解决这一问题。
CIS Kubernetes 基准的自动审核
您可以使用开源工具 kube-bench 根据 CIS Kubernetes 基准测试集群配置。
请务必指定适当的版本。例如:
kube-bench --benchmark BENCHMARK_VERSION
将 BENCHMARK_VERSION 替换为您用于评估集群的 CIS Kubernetes 基准版本。
如需运行特定的 CIS 基准部分(例如主节点、节点或 etcd),请使用 run --targets 命令。例如:
kube-bench run --targets master,node
如需了解详情,请参阅有关运行 kube-bench 以及命令和标志的 kube-bench 文档。