TMAegis
更多 kubernetes 规则

TMA-KUBERNETES-1.2.23

Ensure that the --etcd-certfile and --etcd-keyfile arguments are set as appropriate

高级别 1自动化kubernetes

说明

etcd should be configured to make use of TLS encryption for client connections. Audited on control-plane nodes from the running process arguments (falls back to the kubeadm static pod manifest); SKIPs on nodes without that manifest.

检查方式

审计方法: Shell 命令

shell
set -f
a=$(ps -eo args 2>/dev/null | grep -E '^([^ ]*/)?kube-apiserver( |$)' | head -n 1)
[ -n "$a" ] || a=$(sed -n 's/^[[:space:]]*-[[:space:]]*"\{0,1\}\(--[^"]*\)"\{0,1\}[[:space:]]*$/\1/p' /etc/kubernetes/manifests/kube-apiserver.yaml | tr '\n' ' ')
[ -n "$a" ] || exit 1
g() { printf '%s\n' "$a" | awk -v k="--$1" '{for(i=1;i<=NF;i++){if($i==k&&i<NF)v=$(i+1); else if(index($i,k"=")==1)v=substr($i,length(k)+2)}} END{if(v!="")print v}'; }
has() { printf '%s\n' "$a" | awk -v k="--$1" '{for(i=1;i<=NF;i++) if($i==k||index($i,k"=")==1) f=1} END{exit !f}'; }
ok=1
v=$(g etcd-certfile); [ -n "$v" ] || { echo "noncompliant: --etcd-certfile not set"; ok=0; }
v=$(g etcd-keyfile); [ -n "$v" ] || { echo "noncompliant: --etcd-keyfile not set"; ok=0; }
if [ "$ok" -eq 1 ]; then echo compliant; fi
预期输出
compliant

修复方式

修复方法: 操作指南或基础设施补丁

Follow the Kubernetes documentation and set up the TLS connection between the apiserver and etcd. Then, edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml on the master node and set the etcd certificate and key file parameters. --etcd-certfile=<path/to/client-certificate-file> --etcd-keyfile=<path/to/client-key-file>

属性

操作系统
任意
标签
kubernetesapi-serveretcd
参考
CIS Kubernetes Benchmark v2.1.0 - 1.2.23 Ensure that the --etcd-certfile and --etcd-keyfile arguments are set as appropriate

检查本机

请在您有权审计的机器上运行此命令。扫描为只读操作。

shell
tmaegis scan --target kubernetes