CIS 基准测试
测试说明
kube-bench 是通过运行CIS Kubernetes基准中记录的检查来检查Kubernetes是否安全部署的工具,主要查找不安全的配置参数、敏感的文件权限、不安全的帐户或公开端口等。
测试目标:
测试dce 集群组件是否有不安全的配置参数
报告说明:
PASS]和[FAIL]表示测试已成功运行,并且通过或失败。
[WARN]表示此测试需要进一步关注,例如,它是需要手动运行的测试。
[INFO]是不需要进一步操作的信息输出。
测试方法:
集群组件整体测试
测试步骤
# 获取仓库 git clone https: //github .com /aquasecurity/kube-bench .git # 执行job kubectl apply -f job.yaml # 查看job 是否运行成功 |
测试结果
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
|
kubectl logs kube-bench-pmrlz [INFO] 4 Worker Node Security Configuration [INFO] 4.1 Worker Node Configuration Files [PASS] 4.1.1 Ensure that the kubelet service file permissions are set to 644 or more restrictive (Automated) [PASS] 4.1.2 Ensure that the kubelet service file ownership is set to root:root (Automated) [PASS] 4.1.3 If proxy kubeconfig file exists ensure permissions are set to 644 or more restrictive (Manual) [PASS] 4.1.4 Ensure that the proxy kubeconfig file ownership is set to root:root (Manual) [FAIL] 4.1.5 Ensure that the --kubeconfig kubelet.conf file permissions are set to 644 or more restrictive (Automated) [WARN] 4.1.6 Ensure that the --kubeconfig kubelet.conf file ownership is set to root:root (Manual) [WARN] 4.1.7 Ensure that the certificate authorities file permissions are set to 644 or more restrictive (Manual) [WARN] 4.1.8 Ensure that the client certificate authorities file ownership is set to root:root (Manual) [PASS] 4.1.9 Ensure that the kubelet --config configuration file has permissions set to 644 or more restrictive (Automated) [PASS] 4.1.10 Ensure that the kubelet --config configuration file ownership is set to root:root (Automated) [INFO] 4.2 Kubelet [FAIL] 4.2.1 Ensure that the anonymous-auth argument is set to false (Automated) [FAIL] 4.2.2 Ensure that the --authorization-mode argument is not set to AlwaysAllow (Automated) [FAIL] 4.2.3 Ensure that the --client-ca- file argument is set as appropriate (Automated) [PASS] 4.2.4 Ensure that the -- read -only-port argument is set to 0 (Manual) [PASS] 4.2.5 Ensure that the --streaming-connection-idle-timeout argument is not set to 0 (Manual) [FAIL] 4.2.6 Ensure that the --protect-kernel-defaults argument is set to true (Automated) [PASS] 4.2.7 Ensure that the -- make -iptables-util-chains argument is set to true (Automated) [PASS] 4.2.8 Ensure that the -- hostname -override argument is not set (Manual) [WARN] 4.2.9 Ensure that the --event-qps argument is set to 0 or a level which ensures appropriate event capture (Manual) [WARN] 4.2.10 Ensure that the --tls-cert- file and --tls-private-key- file arguments are set as appropriate (Manual) [PASS] 4.2.11 Ensure that the --rotate-certificates argument is not set to false (Manual) [PASS] 4.2.12 Verify that the RotateKubeletServerCertificate argument is set to true (Manual) [WARN] 4.2.13 Ensure that the Kubelet only makes use of Strong Cryptographic Ciphers (Manual) == Remediations node == 4.1.5 Run the below command (based on the file location on your system) on the each worker node. For example, chmod 644 /etc/kubernetes/kubelet .conf 4.1.6 Run the below command (based on the file location on your system) on the each worker node. For example, chown root:root /etc/kubernetes/kubelet .conf 4.1.7 Run the following command to modify the file permissions of the --client-ca- file chmod 644 <filename> 4.1.8 Run the following command to modify the ownership of the --client-ca- file . chown root:root <filename> 4.2.1 If using a Kubelet config file , edit the file to set authentication: anonymous: enabled to false . If using executable arguments, edit the kubelet service file /lib/systemd/system/kubelet .service on each worker node and set the below parameter in KUBELET_SYSTEM_PODS_ARGS variable. --anonymous-auth= false Based on your system, restart the kubelet service. For example: systemctl daemon-reload systemctl restart kubelet.service 4.2.2 If using a Kubelet config file , edit the file to set authorization: mode to Webhook. If using executable arguments, edit the kubelet service file /lib/systemd/system/kubelet .service on each worker node and set the below parameter in KUBELET_AUTHZ_ARGS variable. --authorization-mode=Webhook Based on your system, restart the kubelet service. For example: systemctl daemon-reload systemctl restart kubelet.service 4.2.3 If using a Kubelet config file , edit the file to set authentication: x509: clientCAFile to the location of the client CA file . If using command line arguments, edit the kubelet service file /lib/systemd/system/kubelet .service on each worker node and set the below parameter in KUBELET_AUTHZ_ARGS variable. --client-ca- file =<path /to/client-ca-file > Based on your system, restart the kubelet service. For example: systemctl daemon-reload systemctl restart kubelet.service 4.2.6 If using a Kubelet config file , edit the file to set protectKernelDefaults: true . If using command line arguments, edit the kubelet service file /lib/systemd/system/kubelet .service on each worker node and set the below parameter in KUBELET_SYSTEM_PODS_ARGS variable. --protect-kernel-defaults= true Based on your system, restart the kubelet service. For example: systemctl daemon-reload systemctl restart kubelet.service 4.2.9 If using a Kubelet config file , edit the file to set eventRecordQPS: to an appropriate level. If using command line arguments, edit the kubelet service file /lib/systemd/system/kubelet .service on each worker node and set the below parameter in KUBELET_SYSTEM_PODS_ARGS variable. Based on your system, restart the kubelet service. For example: systemctl daemon-reload systemctl restart kubelet.service 4.2.10 If using a Kubelet config file , edit the file to set tlsCertFile to the location of the certificate file to use to identify this Kubelet, and tlsPrivateKeyFile to the location of the corresponding private key file . If using command line arguments, edit the kubelet service file /lib/systemd/system/kubelet .service on each worker node and set the below parameters in KUBELET_CERTIFICATE_ARGS variable. --tls-cert- file =<path /to/tls-certificate-file > --tls-private-key- file =<path /to/tls-key-file > Based on your system, restart the kubelet service. For example: systemctl daemon-reload systemctl restart kubelet.service 4.2.13 If using a Kubelet config file , edit the file to set TLSCipherSuites: to TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_128_GCM_SHA256 or to a subset of these values. If using executable arguments, edit the kubelet service file /lib/systemd/system/kubelet .service on each worker node and set the --tls-cipher-suites parameter as follows, or to a subset of these values. --tls-cipher-suites=TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_128_GCM_SHA256 Based on your system, restart the kubelet service. For example: systemctl daemon-reload systemctl restart kubelet.service == Summary node == 12 checks PASS 5 checks FAIL 6 checks WARN 0 checks INFO [INFO] 5 Kubernetes Policies [INFO] 5.1 RBAC and Service Accounts [WARN] 5.1.1 Ensure that the cluster-admin role is only used where required (Manual) [WARN] 5.1.2 Minimize access to secrets (Manual) [WARN] 5.1.3 Minimize wildcard use in Roles and ClusterRoles (Manual) [WARN] 5.1.4 Minimize access to create pods (Manual) [WARN] 5.1.5 Ensure that default service accounts are not actively used. (Manual) [WARN] 5.1.6 Ensure that Service Account Tokens are only mounted where necessary (Manual) [INFO] 5.2 Pod Security Policies [WARN] 5.2.1 Minimize the admission of privileged containers (Manual) [WARN] 5.2.2 Minimize the admission of containers wishing to share the host process ID namespace (Manual) [WARN] 5.2.3 Minimize the admission of containers wishing to share the host IPC namespace (Manual) [WARN] 5.2.4 Minimize the admission of containers wishing to share the host network namespace (Manual) [WARN] 5.2.5 Minimize the admission of containers with allowPrivilegeEscalation (Manual) [WARN] 5.2.6 Minimize the admission of root containers (Manual) [WARN] 5.2.7 Minimize the admission of containers with the NET_RAW capability (Manual) [WARN] 5.2.8 Minimize the admission of containers with added capabilities (Manual) [WARN] 5.2.9 Minimize the admission of containers with capabilities assigned (Manual) [INFO] 5.3 Network Policies and CNI [WARN] 5.3.1 Ensure that the CNI in use supports Network Policies (Manual) [WARN] 5.3.2 Ensure that all Namespaces have Network Policies defined (Manual) [INFO] 5.4 Secrets Management [WARN] 5.4.1 Prefer using secrets as files over secrets as environment variables (Manual) [WARN] 5.4.2 Consider external secret storage (Manual) [INFO] 5.5 Extensible Admission Control [WARN] 5.5.1 Configure Image Provenance using ImagePolicyWebhook admission controller (Manual) [INFO] 5.7 General Policies [WARN] 5.7.1 Create administrative boundaries between resources using namespaces (Manual) [WARN] 5.7.2 Ensure that the seccomp profile is set to docker /default in your pod definitions (Manual) [WARN] 5.7.3 Apply Security Context to Your Pods and Containers (Manual) [WARN] 5.7.4 The default namespace should not be used (Manual) == Remediations policies == 5.1.1 Identify all clusterrolebindings to the cluster-admin role. Check if they are used and if they need this role or if they could use a role with fewer privileges. Where possible, first bind users to a lower privileged role and then remove the clusterrolebinding to the cluster-admin role : kubectl delete clusterrolebinding [name] 5.1.2 Where possible, remove get, list and watch access to secret objects in the cluster. 5.1.3 Where possible replace any use of wildcards in clusterroles and roles with specific objects or actions. 5.1.4 Where possible, remove create access to pod objects in the cluster. 5.1.5 Create explicit service accounts wherever a Kubernetes workload requires specific access to the Kubernetes API server. Modify the configuration of each default service account to include this value automountServiceAccountToken: false 5.1.6 Modify the definition of pods and service accounts which do not need to mount service account tokens to disable it. 5.2.1 Create a PSP as described in the Kubernetes documentation, ensuring that the .spec.privileged field is omitted or set to false . 5.2.2 Create a PSP as described in the Kubernetes documentation, ensuring that the .spec.hostPID field is omitted or set to false . 5.2.3 Create a PSP as described in the Kubernetes documentation, ensuring that the .spec.hostIPC field is omitted or set to false . 5.2.4 Create a PSP as described in the Kubernetes documentation, ensuring that the .spec.hostNetwork field is omitted or set to false . 5.2.5 Create a PSP as described in the Kubernetes documentation, ensuring that the .spec.allowPrivilegeEscalation field is omitted or set to false . 5.2.6 Create a PSP as described in the Kubernetes documentation, ensuring that the .spec.runAsUser.rule is set to either MustRunAsNonRoot or MustRunAs with the range of UIDs not including 0. 5.2.7 Create a PSP as described in the Kubernetes documentation, ensuring that the .spec.requiredDropCapabilities is set to include either NET_RAW or ALL. 5.2.8 Ensure that allowedCapabilities is not present in PSPs for the cluster unless it is set to an empty array. 5.2.9 Review the use of capabilites in applications running on your cluster. Where a namespace contains applicaions which do not require any Linux capabities to operate consider adding a PSP which forbids the admission of containers which do not drop all capabilities. 5.3.1 If the CNI plugin in use does not support network policies, consideration should be given to making use of a different plugin, or finding an alternate mechanism for restricting traffic in the Kubernetes cluster. 5.3.2 Follow the documentation and create NetworkPolicy objects as you need them. 5.4.1 if possible, rewrite application code to read secrets from mounted secret files, rather than from environment variables. 5.4.2 Refer to the secrets management options offered by your cloud provider or a third-party secrets management solution. 5.5.1 Follow the Kubernetes documentation and setup image provenance. 5.7.1 Follow the documentation and create namespaces for objects in your deployment as you need them. 5.7.2 Seccomp is an alpha feature currently. By default, all alpha features are disabled. So, you would need to enable alpha features in the apiserver by passing "--feature- gates=AllAlpha= true " argument. Edit the /etc/kubernetes/apiserver file on the master node and set the KUBE_API_ARGS parameter to "--feature-gates=AllAlpha=true" KUBE_API_ARGS= "--feature-gates=AllAlpha=true" Based on your system, restart the kube-apiserver service. For example: systemctl restart kube-apiserver.service Use annotations to enable the docker /default seccomp profile in your pod definitions. An example is as below: apiVersion: v1 kind: Pod metadata: name: trustworthy-pod annotations: seccomp.security.alpha.kubernetes.io /pod : docker /default spec: containers: - name: trustworthy-container image: sotrustworthy:latest 5.7.3 Follow the Kubernetes documentation and apply security contexts to your pods. For a suggested list of security contexts, you may refer to the CIS Security Benchmark for Docker Containers. 5.7.4 Ensure that namespaces are created to allow for appropriate segregation of Kubernetes resources and that all new resources are created in a specific namespace. == Summary policies == 0 checks PASS 0 checks FAIL 24 checks WARN 0 checks INFO == Summary total == 12 checks PASS 5 checks FAIL 30 checks WARN 0 checks INFO |
结果分析:
5 项测试不通过如下
[FAIL] 4.1.5 Ensure that the --kubeconfig kubelet.conf file permissions are set to 644 or more restrictive (Automated) [FAIL] 4.2.1 Ensure that the anonymous-auth argument is set to false (Automated) [FAIL] 4.2.2 Ensure that the --authorization-mode argument is not set to AlwaysAllow (Automated) [FAIL] 4.2.3 Ensure that the --client-ca- file argument is set as appropriate (Automated) [FAIL] 4.2.6 Ensure that the --protect-kernel-defaults argumen |
原因说明:
因 kubelet 安装部署的差异,kubelet.conf 在dce 集群中的位置为 /etc/daocloud/dce/kubelet/10-dce.conf ,对应的权限为644 、启动指定的文件是需要证书认证的,不存在匿名登陆等情况。
30 项告警如下
1[WARN] 4.1.6 Ensure that the --kubeconfig kubelet.conf file ownership is set to root:root (Manual) 2[WARN] 4.1.7 Ensure that the certificate authorities file permissions are set to 644 or more restrictive (Manual) 3[WARN] 4.1.8 Ensure that the client certificate authorities file ownership is set to root:root (Manual) 4[WARN] 4.2.9 Ensure that the --event-qps argument is set to 0 or a level which ensures appropriate event capture (Manual) 5[WARN] 4.2.10 Ensure that the --tls-cert- file and --tls-private-key- file arguments are set as appropriate (Manual) 6[WARN] 4.2.13 Ensure that the Kubelet only makes use of Strong Cryptographic Ciphers (Manual) checks WARN 7[WARN] 5.1.1 Ensure that the cluster-admin role is only used where required (Manual) 8[WARN] 5.1.2 Minimize access to secrets (Manual) 9[WARN] 5.1.3 Minimize wildcard use in Roles and ClusterRoles (Manual) 10[WARN] 5.1.4 Minimize access to create pods (Manual) 11[WARN] 5.1.5 Ensure that default service accounts are not actively used. (Manual) 12[WARN] 5.1.6 Ensure that Service Account Tokens are only mounted where necessary (Manual) 13[WARN] 5.2.1 Minimize the admission of privileged containers (Manual) 14[WARN] 5.2.2 Minimize the admission of containers wishing to share the host process ID namespace (Manual) 15[WARN] 5.2.3 Minimize the admission of containers wishing to share the host IPC namespace (Manual) 16[WARN] 5.2.4 Minimize the admission of containers wishing to share the host network namespace (Manual) 17[WARN] 5.2.5 Minimize the admission of containers with allowPrivilegeEscalation (Manual) 18[WARN] 5.2.6 Minimize the admission of root containers (Manual) 19[WARN] 5.2.7 Minimize the admission of containers with the NET_RAW capability (Manual) 20[WARN] 5.2.8 Minimize the admission of containers with added capabilities (Manual) 21[WARN] 5.2.9 Minimize the admission of containers with capabilities assigned (Manual) 22[WARN] 5.3.1 Ensure that the CNI in use supports Network Policies (Manual) 23[WARN] 5.3.2 Ensure that all Namespaces have Network Policies defined (Manual) 24[WARN] 5.4.1 Prefer using secrets as files over secrets as environment variables (Manual) 25[WARN] 5.4.2 Consider external secret storage (Manual) 26[WARN] 5.5.1 Configure Image Provenance using ImagePolicyWebhook admission controller (Manual) 27[WARN] 5.7.1 Create administrative boundaries between resources using namespaces (Manual) 28[WARN] 5.7.2 Ensure that the seccomp profile is set to docker /default in your pod definitions (Manual) 29[WARN] 5.7.3 Apply Security Context to Your Pods and Containers (Manual) 30[WARN] 5.7.4 The default namespace should not be used (Manual) |
原因分析:
1-6: 因kubelet 安装部署的差异,kubelet.conf 在dce 集群中的位置为 /etc/daocloud/dce/kubelet/10-dce.conf ,对应的权限为644 、启动指定的文件是需要证书认证的,不存在匿名登陆等情况。
7-12: cluster-admin 为默认的 ClusterRoleBinding 权限绑定,权限可根据实际使用进行调整。
13-21: dce 集群对上述集群策略是支持的
22-23: 网络插件 calico 支持网络策略,用户可根据实际情况调整
24-30: 权限资源限制可根据用户实际情况进行调整,平台本身已支持
测试master 节点
测试步骤
kubectl apply -f job-master.yaml |
测试结果
结果分析
26 项检测通过
28 项检测失败,具体如下
失败原因:因部署方式的差异 dce 集群组件 etcd 、controller、scheduler、controller-manager 等是以静态pod 的方式运行,组件的权限和cis 参考的权限基本一致(644)如下
测试计算节点
测试步骤
测试结果
[INFO] 4 Worker Node Security Configuration [INFO] 4.1 Worker Node Configuration Files [PASS] 4.1.1 Ensure that the kubelet service file permissions are set to 644 or more restrictive (Automated) [PASS] 4.1.2 Ensure that the kubelet service file ownership is set to root:root (Automated) [PASS] 4.1.3 If proxy kubeconfig file exists ensure permissions are set to 644 or more restrictive (Manual) [PASS] 4.1.4 Ensure that the proxy kubeconfig file ownership is set to root:root (Manual) [FAIL] 4.1.5 Ensure that the --kubeconfig kubelet.conf file permissions are set to 644 or more restrictive (Automated) [WARN] 4.1.6 Ensure that the --kubeconfig kubelet.conf file ownership is set to root:root (Manual) [WARN] 4.1.7 Ensure that the certificate authorities file permissions are set to 644 or more restrictive (Manual) [WARN] 4.1.8 Ensure that the client certificate authorities file ownership is set to root:root (Manual) [PASS] 4.1.9 Ensure that the kubelet --config configuration file has permissions set to 644 or more restrictive (Automated) [PASS] 4.1.10 Ensure that the kubelet --config configuration file ownership is set to root:root (Automated) [INFO] 4.2 Kubelet [FAIL] 4.2.1 Ensure that the anonymous-auth argument is set to false (Automated) [FAIL] 4.2.2 Ensure that the --authorization-mode argument is not set to AlwaysAllow (Automated) [FAIL] 4.2.3 Ensure that the --client-ca- file argument is set as appropriate (Automated) [PASS] 4.2.4 Ensure that the -- read -only-port argument is set to 0 (Manual) [PASS] 4.2.5 Ensure that the --streaming-connection-idle-timeout argument is not set to 0 (Manual) [FAIL] 4.2.6 Ensure that the --protect-kernel-defaults argument is set to true (Automated) [PASS] 4.2.7 Ensure that the -- make -iptables-util-chains argument is set to true (Automated) [PASS] 4.2.8 Ensure that the -- hostname -override argument is not set (Manual) [WARN] 4.2.9 Ensure that the --event-qps argument is set to 0 or a level which ensures appropriate event capture (Manual) [WARN] 4.2.10 Ensure that the --tls-cert- file and --tls-private-key- file arguments are set as appropriate (Manual) [PASS] 4.2.11 Ensure that the --rotate-certificates argument is not set to false (Manual) [PASS] 4.2.12 Verify that the RotateKubeletServerCertificate argument is set to true (Manual) [WARN] 4.2.13 Ensure that the Kubelet only makes use of Strong Cryptographic Ciphers (Manual) == Remediations node == 4.1.5 Run the below command (based on the file location on your system) on the each worker node. For example, chmod 644 /etc/kubernetes/kubelet .conf 4.1.6 Run the below command (based on the file location on your system) on the each worker node. For example, chown root:root /etc/kubernetes/kubelet .conf 4.1.7 Run the following command to modify the file permissions of the --client-ca- file chmod 644 <filename> 4.1.8 Run the following command to modify the ownership of the --client-ca- file . chown root:root <filename> 4.2.1 If using a Kubelet config file , edit the file to set authentication: anonymous: enabled to false . If using executable arguments, edit the kubelet service file /lib/systemd/system/kubelet .service on each worker node and set the below parameter in KUBELET_SYSTEM_PODS_ARGS variable. --anonymous-auth= false Based on your system, restart the kubelet service. For example: systemctl daemon-reload systemctl restart kubelet.service 4.2.2 If using a Kubelet config file , edit the file to set authorization: mode to Webhook. If using executable arguments, edit the kubelet service file /lib/systemd/system/kubelet .service on each worker node and set the below parameter in KUBELET_AUTHZ_ARGS variable. --authorization-mode=Webhook Based on your system, restart the kubelet service. For example: systemctl daemon-reload systemctl restart kubelet.service 4.2.3 If using a Kubelet config file , edit the file to set authentication: x509: clientCAFile to the location of the client CA file . If using command line arguments, edit the kubelet service file /lib/systemd/system/kubelet .service on each worker node and set the below parameter in KUBELET_AUTHZ_ARGS variable. --client-ca- file =<path /to/client-ca-file > Based on your system, restart the kubelet service. For example: systemctl daemon-reload systemctl restart kubelet.service 4.2.6 If using a Kubelet config file , edit the file to set protectKernelDefaults: true . If using command line arguments, edit the kubelet service file /lib/systemd/system/kubelet .service on each worker node and set the below parameter in KUBELET_SYSTEM_PODS_ARGS variable. --protect-kernel-defaults= true Based on your system, restart the kubelet service. For example: systemctl daemon-reload systemctl restart kubelet.service 4.2.9 If using a Kubelet config file , edit the file to set eventRecordQPS: to an appropriate level. If using command line arguments, edit the kubelet service file /lib/systemd/system/kubelet .service on each worker node and set the below parameter in KUBELET_SYSTEM_PODS_ARGS variable. Based on your system, restart the kubelet service. For example: systemctl daemon-reload systemctl restart kubelet.service 4.2.10 If using a Kubelet config file , edit the file to set tlsCertFile to the location of the certificate file to use to identify this Kubelet, and tlsPrivateKeyFile to the location of the corresponding private key file . If using command line arguments, edit the kubelet service file /lib/systemd/system/kubelet .service on each worker node and set the below parameters in KUBELET_CERTIFICATE_ARGS variable. --tls-cert- file =<path /to/tls-certificate-file > --tls-private-key- file =<path /to/tls-key-file > Based on your system, restart the kubelet service. For example: systemctl daemon-reload systemctl restart kubelet.service 4.2.13 If using a Kubelet config file , edit the file to set TLSCipherSuites: to TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_128_GCM_SHA256 or to a subset of these values. If using executable arguments, edit the kubelet service file /lib/systemd/system/kubelet .service on each worker node and set the --tls-cipher-suites parameter as follows, or to a subset of these values. --tls-cipher-suites=TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_128_GCM_SHA256 Based on your system, restart the kubelet service. For example: systemctl daemon-reload systemctl restart kubelet.service == Summary node == 12 checks PASS 5 checks FAIL 6 checks WARN 0 checks INFO == Summary total == 12 checks PASS 5 checks FAIL 6 checks WARN 0 checks INFO |
结果分析
12 项测通过
5 项失败如下
[FAIL] 4.1.5 Ensure that the --kubeconfig kubelet.conf file permissions are set to 644 or more restrictive (Automated) [FAIL] 4.2.1 Ensure that the anonymous-auth argument is set to false (Automated) [FAIL] 4.2.2 Ensure that the --authorization-mode argument is not set to AlwaysAllow (Automated) [FAIL] 4.2.3 Ensure that the --client-ca- file argument is set as appropriate (Automated) [FAIL] 4.2.6 Ensure that the --protect-kernel-defaults argument is set to true (Automated) |
失败原因:因kubelet 安装部署的差异,kubelet.conf 在dce 集群中的位置为 /etc/daocloud/dce/kubelet/10-dce.conf ,对应的权限为644 、启动指定的文件是需要证书认证的,不存在匿名登陆等情况。
6 项告警如下:
[WARN] 4.1.6 Ensure that the --kubeconfig kubelet.conf file ownership is set to root:root (Manual) [WARN] 4.1.7 Ensure that the certificate authorities file permissions are set to 644 or more restrictive (Manual) [WARN] 4.1.8 Ensure that the client certificate authorities file ownership is set to root:root (Manual) [WARN] 4.2.9 Ensure that the --event-qps argument is set to 0 or a level which ensures appropriate event capture (Manual) [WARN] 4.2.10 Ensure that the --tls-cert- file and --tls-private-key- file arguments are set as appropriate (Manual) [WARN] 4.2.13 Ensure that the Kubelet only makes use of Strong Cryptographic Ciphers (Manual) |
报警原因:kubelet 与apiserver 等组件交互的时候是需要通过证书加密认证的。
参考: