@@ -36,13 +36,19 @@ Kubernetes 项目建议及时升级到最新的补丁版本,并确保你正在
36
36
<!--
37
37
You should be familiar with [PKI certificates and requirements in Kubernetes](/docs/setup/best-practices/certificates/).
38
38
39
+ You should be familiar with how to pass a [configuration](/docs/reference/config-api/kubeadm-config.v1beta4/) file to the kubeadm commands.
40
+ -->
41
+ 你应该熟悉 [ Kubernetes 中的 PKI 证书和要求] ( /zh-cn/docs/setup/best-practices/certificates/ ) 。
42
+
43
+ 你应该熟悉如何将一个[ 配置] ( /zh-cn/docs/reference/config-api/kubeadm-config.v1beta4/ ) 文件传递给
44
+ kubeadm 命令。
45
+
46
+ <!--
39
47
This guide covers the usage of the `openssl` command (used for manual certificate signing,
40
48
if you choose that approach), but you can use your preferred tools.
41
49
42
50
Some of the steps here use `sudo` for administrator access. You can use any equivalent tool.
43
51
-->
44
- 你应该熟悉 [ Kubernetes 中的 PKI 证书和要求] ( /zh-cn/docs/setup/best-practices/certificates/ ) 。
45
-
46
52
本指南将介绍如何使用 ` openssl ` 命令(用于手动证书签名),但你可以使用你喜欢的工具。
47
53
48
54
这里的一些步骤使用 ` sudo ` 来获取管理员访问权限。你可以使用任何等效的工具。
@@ -78,6 +84,66 @@ and kubeadm will use this CA for signing the rest of the certificates.
78
84
例如,这意味着你可以将现有的 CA 复制到 ` /etc/kubernetes/pki/ca.crt ` 和
79
85
` /etc/kubernetes/pki/ca.key ` 中,而 kubeadm 将使用此 CA 对其余证书进行签名。
80
86
87
+ <!--
88
+ ## Choosing an encryption algorithm {#choosing-encryption-algorithm}
89
+
90
+ kubeadm allows you to choose an encryption algorithm that is used for creating
91
+ public and private keys. That can be done by using the `encryptionAlgorithm` field of the
92
+ kubeadm configuration:
93
+ -->
94
+ ## 选择加密算法 {#choosing-encryption-algorithm}
95
+
96
+ kubeadm 允许你选择用于创建公钥和私钥的加密算法。这可以通过使用
97
+ kubeadm 配置中的 ` encryptionAlgorithm ` 字段来实现。
98
+
99
+ ``` yaml
100
+ apiVersion : kubeadm.k8s.io/v1beta4
101
+ kind : ClusterConfiguration
102
+ encryptionAlgorithm : <ALGORITHM>
103
+ ` ` `
104
+
105
+ <!--
106
+ ` <ALGORITHM>` can be one of `RSA-2048` (default), `RSA-3072`, `RSA-4096` or `ECDSA-P256`.
107
+ -->
108
+ ` <ALGORITHM>` 可以是 `RSA-2048`(默认)、`RSA-3072`、`RSA-4096`
109
+ 或 `ECDSA-P256` 之一。
110
+
111
+ <!--
112
+ # # Choosing certificate validity period {#choosing-cert-validity-period}
113
+
114
+ kubeadm allows you to choose the validity period of CA and leaf certificates.
115
+ That can be done by using the `certificateValidityPeriod` and `caCertificateValidityPeriod`
116
+ fields of the kubeadm configuration :
117
+ -->
118
+ # # 选择证书有效期 {#choosing-cert-validity-period}
119
+
120
+ kubeadm 允许你选择 CA 和 leaf 证书的有效期。
121
+ 这可以通过使用 kubeadm 配置的 `certificateValidityPeriod` 和 `caCertificateValidityPeriod`
122
+ 字段来完成:
123
+
124
+ <!--
125
+ ` ` ` yaml
126
+ apiVersion: kubeadm.k8s.io/v1beta4
127
+ kind: ClusterConfiguration
128
+ certificateValidityPeriod: 8760h # Default: 365 days × 24 hours = 1 year
129
+ caCertificateValidityPeriod: 87600h # Default: 365 days × 24 hours * 10 = 10 years
130
+ ` ` `
131
+ -->
132
+ ` ` ` yaml
133
+ apiVersion: kubeadm.k8s.io/v1beta4
134
+ kind: ClusterConfiguration
135
+ certificateValidityPeriod: 8760h # 默认:365 天 × 24 小时 = 1 年
136
+ caCertificateValidityPeriod: 87600h # 默认:365 天 × 24 小时 * 10 = 10 年
137
+ ` ` `
138
+
139
+ <!--
140
+ The values of the fields follow the accepted format for
141
+ [Go's `time.Duration` values](https://pkg.go.dev/time#ParseDuration), with the longest supported
142
+ unit being `h` (hours).
143
+ -->
144
+ 字段的值遵循 [Go 语言的 `time.Duration` 格式](https://pkg.go.dev/time#ParseDuration),
145
+ 支持的最长单位为 `h`(小时)。
146
+
81
147
<!--
82
148
# # External CA mode {#external-ca-mode}
83
149
@@ -178,7 +244,8 @@ Alternatively, it is possible to use kubeadm phase commands to automate this pro
178
244
仅在将执行 `kubeadm init` 的第一个节点上需要此文件。
179
245
- 请注意,一些文件如 `pki/sa.*`、`pki/front-proxy-ca.*` 和 `pki/etc/ca.*`
180
246
在控制平面各节点上是相同的,你可以一次性生成它们并[手动将其分发](/zh-cn/docs/setup/production-environment/tools/kubeadm/high-availability/#manual-certs)到将执行
181
- ` kubeadm join ` 的节点,或者你可以使用 ` kubeadm init ` 的 [ ` --upload-certs ` ] ( /zh-cn/docs/setup/product-environment/tools/kubeadm/high-availability/#stacked-control-plane-and-etcd-nodes )
247
+ ` kubeadm join` 的节点,或者你可以使用 `kubeadm init` 的
248
+ [`--upload-certs`](/zh-cn/docs/setup/product-environment/tools/kubeadm/high-availability/#stacked-control-plane-and-etcd-nodes)
182
249
和 `kubeadm join` 的 `--certificate-key` 特性来执行自动分发。
183
250
184
251
<!--
@@ -443,7 +510,7 @@ If you're creating a new cluster, you can use a kubeadm
443
510
[configuration file](/docs/reference/config-api/kubeadm-config.v1beta4/) :
444
511
-->
445
512
如果你正在创建一个新的集群,你可以使用 kubeadm
446
- 的[配置文件](/zh-cn/docs/reference/config-api/kubeadm-config.v1beta4/)。
513
+ 的[配置文件](/zh-cn/docs/reference/config-api/kubeadm-config.v1beta4/):
447
514
448
515
` ` ` yaml
449
516
apiVersion: kubeadm.k8s.io/v1beta4
@@ -459,7 +526,7 @@ controllerManager:
459
526
<!--
460
527
# ## Create certificate signing requests (CSR)
461
528
-->
462
- # ## 创建证书签名请求 ( CSR) {#create-certificate-signing-requests-csr}
529
+ # ## 创建证书签名请求( CSR) {#create-certificate-signing-requests-csr}
463
530
464
531
<!--
465
532
See [Create CertificateSigningRequest](/docs/reference/access-authn-authz/certificate-signing-requests/#create-certificatessigningrequest)
@@ -618,9 +685,8 @@ If you are looking for a solution for automatic approval of these CSRs it is rec
618
685
that you contact your cloud provider and ask if they have a CSR signer that verifies
619
686
the node identity with an out of band mechanism.
620
687
-->
621
- 如果你在寻找一种能够自动批准这些 CSR 的解决方案,建议你与你的云提供商
622
- 联系,询问他们是否有 CSR 签名组件,用来以带外(out-of-band)的方式检查
623
- 节点的标识符。
688
+ 如果你在寻找一种能够自动批准这些 CSR 的解决方案,建议你与你的云提供商联系,
689
+ 询问他们是否有 CSR 签名组件,用来以带外(out-of-band)的方式检查节点的标识符。
624
690
625
691
{{% thirdparty-content %}}
626
692
@@ -911,7 +977,8 @@ on secondary control plane and on workers nodes (all nodes that call `kubeadm jo
911
977
That is because the active kube-controller-manager will be responsible
912
978
for signing new kubelet client certificates.
913
979
-->
914
- 请注意,这也意味着自动 [kubelet 客户端证书轮换](/zh-cn/docs/tasks/tls/certificate-rotation/#enabling-client-certificate-rotation)将被禁用。
980
+ 请注意,这也意味着自动
981
+ [kubelet 客户端证书轮换](/zh-cn/docs/tasks/tls/certificate-rotation/#enabling-client-certificate-rotation)将被禁用。
915
982
如果是这样,在证书即将到期时,你必须生成新的 `kubelet.conf.csr`,签署证书,
916
983
将其嵌入到 `kubelet.conf` 中并重新启动 kubelet。
917
984
@@ -959,8 +1026,8 @@ Based on the explanation in
959
1026
[Considerations for kubelet.conf](#considerations-kubelet-conf) keep or delete
960
1027
the `kubelet.conf` and `kubelet.conf.csr` files.
961
1028
-->
962
- 如果要使用外部 etcd,请阅读 [kubeadm 使用外部 etcd](/zh-cn/docs/setup/production-environment/tools/kubeadm/high-availability/#external-etcd-nodes)指南了解
963
- kubeadm 和 etcd 节点上需要哪些 CSR 文件。
1029
+ 如果要使用外部 etcd,请阅读 [kubeadm 使用外部 etcd](/zh-cn/docs/setup/production-environment/tools/kubeadm/high-availability/#external-etcd-nodes)
1030
+ 指南了解 kubeadm 和 etcd 节点上需要哪些 CSR 文件。
964
1031
你可以删除 `/etc/kubernetes/pki/etcd` 下的其他 `.csr` 和 `.key` 文件。
965
1032
966
1033
根据 [kubelet.conf 的注意事项](#considerations-kubelet-conf)中的说明,
@@ -1034,12 +1101,45 @@ present in the `/etc/kubernetes` tree.
1034
1101
1035
1102
<!--
1036
1103
` ` ` bash
1104
+ #!/bin/bash
1105
+
1037
1106
# Set certificate expiration time in days
1107
+ DAYS=365
1108
+
1038
1109
# Process all CSR files except those for front-proxy and etcd
1039
- # Trim the extension
1110
+ find ./ -name "*.csr" | grep -v "pki/etcd" | grep -v "front-proxy" | while read -r FILE;
1111
+ do
1112
+ echo "* Processing ${FILE} ..."
1113
+ FILE=${FILE%.*} # Trim the extension
1114
+ if [ -f "./pki/ca.srl" ]; then
1115
+ SERIAL_FLAG="-CAserial ./pki/ca.srl"
1116
+ else
1117
+ SERIAL_FLAG="-CAcreateserial"
1118
+ fi
1119
+ openssl x509 -req -days "${DAYS}" -CA ./pki/ca.crt -CAkey ./pki/ca.key ${SERIAL_FLAG} \
1120
+ -in "${FILE}.csr" -out "${FILE}.crt"
1121
+ sleep 2
1122
+ done
1123
+
1040
1124
# Process all etcd CSRs
1041
- # Trim the extension
1125
+ find ./pki/etcd -name "*.csr" | while read -r FILE;
1126
+ do
1127
+ echo "* Processing ${FILE} ..."
1128
+ FILE=${FILE%.*} # Trim the extension
1129
+ if [ -f "./pki/etcd/ca.srl" ]; then
1130
+ SERIAL_FLAG=-CAserial ./pki/etcd/ca.srl
1131
+ else
1132
+ SERIAL_FLAG=-CAcreateserial
1133
+ fi
1134
+ openssl x509 -req -days "${DAYS}" -CA ./pki/etcd/ca.crt -CAkey ./pki/etcd/ca.key ${SERIAL_FLAG} \
1135
+ -in "${FILE}.csr" -out "${FILE}.crt"
1136
+ done
1137
+
1042
1138
# Process front-proxy CSRs
1139
+ echo "* Processing ./pki/front-proxy-client.csr ..."
1140
+ openssl x509 -req -days "${DAYS}" -CA ./pki/front-proxy-ca.crt -CAkey ./pki/front-proxy-ca.key -CAcreateserial \
1141
+ -in ./pki/front-proxy-client.csr -out ./pki/front-proxy-client.crt
1142
+ ` ` `
1043
1143
-->
1044
1144
` ` ` bash
1045
1145
#!/bin/bash
0 commit comments