Skip to content

Commit d4121d4

Browse files
authored
Merge pull request #25420 from jiaj12/patch-36
Update manual-rotation-of-ca-certificates.md
2 parents 13561ab + 653d4b6 commit d4121d4

File tree

1 file changed

+34
-15
lines changed

1 file changed

+34
-15
lines changed

content/zh/docs/tasks/tls/manual-rotation-of-ca-certificates.md

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,34 +61,54 @@ Configurations with a single API server will experience unavailability while the
6161
`front-proxy-client.key`)分发到所有控制面节点,放在其 Kubernetes 证书目录下。
6262

6363
<!--
64-
1. Update *Kubernetes controller manager's* `-root-ca-file` to include both old and new CA and restart controller manager.
64+
1. Update {{< glossary_tooltip text="kube-controller-manager" term_id="kube-controller-manager" >}}'s `--root-ca-file` to
65+
include both old and new CA. Then restart the component.
6566
6667
Any service account created after this point will get secrets that include both old and new CAs.
67-
68-
Remove the flag `-client-ca-file` from the *Kubernetes controller manager* configuration.
69-
You can also replace the existing client CA file or change this configuration item to reference a new, updated CA.
70-
[Issue 1350](https://github.com/kubernetes/kubeadm/issues/1350) tracks an issue with *Kubernetes controller manager* being unable to accept a CA bundle.
68+
69+
{{< note >}}
70+
The files specified by the kube-controller-manager flags `--client-ca-file` and `--cluster-signing-cert-file`
71+
cannot be CA bundles. If these flags and `--root-ca-file` point to the same `ca.crt` file which is now a
72+
bundle (includes both old and new CA) you will face an error. To workaround this problem you can copy the new CA to a separate
73+
file and make the flags `--client-ca-file` and `--cluster-signing-cert-file` point to the copy. Once `ca.crt` is no longer
74+
a bundle you can restore the problem flags to point to `ca.crt` and delete the copy.
75+
{{< /note >}}
7176
-->
72-
2. 更新控制器管理器的 `--root-ca-file` 标志,使之同时包含老的和新的 CA,之后重启控制器管理器。
77+
2. 更新 {{< glossary_tooltip text="kube-controller-manager" term_id="kube-controller-manager" >}} 的
78+
`--root-ca-file` 标志,使之同时包含老的和新的 CA,之后重启组件。
7379

7480
自此刻起,所创建的所有服务账号都会获得同时包含老的 CA 和新的 CA 的 Secret。
7581

7682
{{< note >}}
77-
去掉控制器管理器的 `-client-ca-file` 标志。
78-
你也可以替换客户端 CA 文件或者将此配置条目指向新的、更新过的 CA。
79-
[Issue 1350](https://github.com/kubernetes/kubeadm/issues/1350) 用来跟踪
80-
控制器管理器无法接受 CA 包的问题。
83+
kube-controller-manager 标志 `--client-ca-file``--cluster-signing-cert-file` 所引用的文件
84+
不能是 CA 证书包。如果这些标志和 `--root-ca-file` 指向同一个 `ca.crt` 包文件(包含老的和新的 CA 证书),
85+
你将会收到出错信息。
86+
要解决这个问题,可以将新的 CA 证书复制到单独的文件中,并将 `--client-ca-file``--cluster-signing-cert-file`
87+
标志指向该副本。一旦 `ca.crt` 不再是证书包文件,就可以恢复有问题的标志指向 `ca.crt` 并删除该副本。
8188
{{< /note >}}
8289

8390
<!--
84-
1. Update all service account tokens to include both old and new CA certificates.
91+
1. Update all service account tokens to include both old and new CA certificates.
8592
8693
If any pods are started before new CA is used by API servers, they will get this update and trust both old and new CAs.
8794
-->
8895
3. 更新所有服务账号令牌,使之同时包含老的和新的 CA 证书。
8996

9097
如果在 API 服务器使用新的 CA 之前启动了新的 Pod,这些 Pod
9198
也会获得此更新并且同时信任老的和新的 CA 证书。
99+
<!--
100+
```shell
101+
base64_encoded_ca="$(base64 <path to file containing both old and new CAs>)"
102+
103+
for namespace in $(kubectl get ns --no-headers | awk '{print $1}'); do
104+
for token in $(kubectl get secrets --namespace "$namespace" --field-selector type=kubernetes.io/service-account-token -o name); do
105+
kubectl get $token --namespace "$namespace" -o yaml | \
106+
/bin/sed "s/\(ca.crt:\).*/\1 ${base64_encoded_ca}" | \
107+
kubectl apply -f -
108+
done
109+
done
110+
```
111+
-->
92112

93113
```shell
94114
base64_encoded_ca="$(base64 <path to file containing both old and new CAs>)"
@@ -111,7 +131,7 @@ Configurations with a single API server will experience unavailability while the
111131
1. Append the both old and new CA to the file against `-client-ca-file` flag in the `kube-scheduler` configuration.
112132
-->
113133
4. 重启所有使用集群内配置的 Pods(例如:`kube-proxy``coredns` 等),以便这些 Pod 能够使用
114-
来自服务账号 Secret 中的、已更新的证书机构数据。
134+
来自 *ServiceAccount* Secret 中的、已更新的证书机构数据。
115135

116136
* 确保 `coredns``kube-proxy` 和其他使用集群内配置的 Pod 都正按预期方式工作。
117137

@@ -151,7 +171,7 @@ Configurations with a single API server will experience unavailability while the
151171
-->
152172
8. 遵循下列步骤执行滚动更新
153173

154-
1. 重新启动所有其他[被聚合的 API 服务器](/zh/docs/concepts/extend-kubernetes/api-extension/apiserver-aggregation/)
174+
1. 重新启动所有其他 *[被聚合的 API 服务器](/zh/docs/concepts/extend-kubernetes/api-extension/apiserver-aggregation/)*
155175
或者 *Webhook 处理程序*,使之信任新的 CA 证书。
156176

157177
2. 在所有节点上更新 kubelet 配置中的 `clientCAFile` 所指文件以及 kubelet.conf 中的
@@ -168,7 +188,7 @@ Configurations with a single API server will experience unavailability while the
168188
If you changed the private keys then update these in the Kubernetes certificates directory as well.
169189
-->
170190
3. 使用用新的 CA 签名的证书
171-
`apiserver.crt``apiserver-kubelet-client.crt``front-proxy-client.crt`
191+
`apiserver.crt``apiserver-kubelet-client.crt``front-proxy-client.crt`
172192
来重启 API 服务器。
173193
你可以使用现有的私钥,也可以使用新的私钥。
174194
如果你改变了私钥,则要将更新的私钥也放到 Kubernetes 证书目录下。
@@ -275,4 +295,3 @@ Configurations with a single API server will experience unavailability while the
275295

276296
1. 重启 kubelet,移除 `clientCAFile` 标志所指向的文件以及 kubelet kubeconfig 文件中
277297
的老的 CA 数据。
278-

0 commit comments

Comments
 (0)