From 1dc944e43df8ed2c6a8fb74d6637c5e7c2ae8ebf Mon Sep 17 00:00:00 2001 From: windsonsea Date: Fri, 13 Dec 2024 14:25:55 +0800 Subject: [PATCH] [zh] Sync setup-tools/kubeadm/kubeadm-init.md --- .../setup-tools/kubeadm/kubeadm-init.md | 200 +++++++++++------- 1 file changed, 118 insertions(+), 82 deletions(-) diff --git a/content/zh-cn/docs/reference/setup-tools/kubeadm/kubeadm-init.md b/content/zh-cn/docs/reference/setup-tools/kubeadm/kubeadm-init.md index 0372a23460..c1ba718450 100644 --- a/content/zh-cn/docs/reference/setup-tools/kubeadm/kubeadm-init.md +++ b/content/zh-cn/docs/reference/setup-tools/kubeadm/kubeadm-init.md @@ -7,7 +7,7 @@ weight: 20 此命令初始化一个 Kubernetes 控制平面节点。 @@ -21,7 +21,7 @@ This command initializes a Kubernetes control-plane node. ### Init 命令的工作流程 {#init-workflow} `kubeadm init` 命令通过执行下列步骤来启动一个 Kubernetes 控制平面节点。 @@ -40,20 +40,20 @@ following steps: 1. Generates a self-signed CA to set up identities for each component in the cluster. The user can provide their own CA cert and/or key by dropping it in the cert directory configured via `--cert-dir` (`/etc/kubernetes/pki` by default). - The APIServer certs will have additional SAN entries for any `--apiserver-cert-extra-sans` arguments, lowercased if necessary. + The API server certs will have additional SAN entries for any `--apiserver-cert-extra-sans` arguments, lowercased if necessary. --> 2. 生成一个自签名的 CA 证书来为集群中的每一个组件建立身份标识。 用户可以通过将其放入 `--cert-dir` 配置的证书目录中(默认为 `/etc/kubernetes/pki`) 来提供他们自己的 CA 证书以及/或者密钥。 - APIServer 证书将为任何 `--apiserver-cert-extra-sans` 参数值提供附加的 SAN 条目,必要时将其小写。 + API 服务器证书将为所有 `--apiserver-cert-extra-sans` 参数值提供附加的 SAN 条目,必要时将其小写。 -3. 将 kubeconfig 文件写入 `/etc/kubernetes/` 目录以便 kubelet、控制器管理器和调度器用来连接到 +3. 将 kubeconfig 文件写入 `/etc/kubernetes/` 目录以便 kubelet、控制器管理器和调度器连接到 API 服务器,它们每一个都有自己的身份标识。再编写额外的 kubeconfig 文件,将 kubeadm 作为管理实体(`admin.conf`)和可以绕过 RBAC 的超级管理员用户(`super-admin.conf`)。 @@ -76,16 +76,16 @@ following steps: 一旦控制平面的 Pod 都运行起来,`kubeadm init` 的工作流程就继续往下执行。 5. 对控制平面节点应用标签和污点标记以便不会在它上面运行其它的工作负载。 6. 生成令牌,将来其他节点可使用该令牌向控制平面注册自己。如 [kubeadm token](/zh-cn/docs/reference/setup-tools/kubeadm/kubeadm-token/) @@ -104,7 +104,7 @@ following steps: - Configure auto-approval for new CSR requests. - See [kubeadm join](/docs/reference/setup-tools/kubeadm/kubeadm-join/) for additional info. + See [kubeadm join](/docs/reference/setup-tools/kubeadm/kubeadm-join/) for additional information. --> 7. 为了使得节点能够遵照[启动引导令牌](/zh-cn/docs/reference/access-authn-authz/bootstrap-tokens/)和 [TLS 启动引导](/zh-cn/docs/reference/access-authn-authz/kubelet-tls-bootstrapping/) @@ -137,11 +137,11 @@ following steps: ### 在 kubeadm 中使用 init 阶段 {#init-phases} -Kubeadm 允许你使用 `kubeadm init phase` 命令分阶段创建控制平面节点。 +kubeadm 允许你使用 `kubeadm init phase` 命令分阶段创建控制平面节点。 配置文件的功能仍然处于 Beta 状态并且在将来的版本中可能会改变。 {{< /caution >}} @@ -226,7 +226,7 @@ The config file is still considered beta and may change in future versions. It's possible to configure `kubeadm init` with a configuration file instead of command line flags, and some more advanced features may only be available as configuration file options. This file is passed using the `--config` flag and it must -contain a `ClusterConfiguration` structure and optionally more structures separated by `---\n` +contain a `ClusterConfiguration` structure and optionally more structures separated by `---\n`. Mixing `--config` with others flags may not be allowed in some cases. --> 通过一份配置文件而不是使用命令行参数来配置 `kubeadm init` 命令是可能的, @@ -260,11 +260,11 @@ For more information on the fields and usage of the configuration you can naviga ### 使用 kubeadm init 时设置特性门控 {#feature-gates} -Kubeadm 支持一组独有的特性门控,只能在 `kubeadm init` 创建集群期间使用。 +kubeadm 支持一组独有的特性门控,只能在 `kubeadm init` 创建集群期间使用。 这些特性可以控制集群的行为。特性门控会在毕业到 GA 后被移除。 @@ -305,8 +305,8 @@ Feature | Default | Alpha | Beta | GA 特性 | 默认值 | Alpha | Beta | GA :-------|:--------|:------|:-----|:---- `ControlPlaneKubeletLocalMode` | `false` | 1.31 | - | - -`EtcdLearnerMode` | `true` | 1.27 | 1.29 | - -`PublicKeysECDSA` | `false` | 1.19 | - | - +`EtcdLearnerMode` | `true` | 1.27 | 1.29 | 1.32 +`NodeLocalCRISocket` | `false` | 1.32 | - | - `WaitForAllControlPlaneComponents` | `false` | 1.30 | - | - {{< /table >}} @@ -325,8 +325,8 @@ Feature gate descriptions: `ControlPlaneKubeletLocalMode` : 启用此特性门控后,当加入新的控制平面节点时, @@ -336,46 +336,62 @@ policy during rolling upgrades. `EtcdLearnerMode` : 启用此特性门控后,当加入新的控制平面节点时,将创建一个新的 etcd 成员作为学习者(learner),并仅在 etcd 数据完全对齐后进级为投票成员(voting member)。 -`PublicKeysECDSA` -: 可用于创建集群时使用 ECDSA 证书而不是默认 RSA 算法。 - 支持用 `kubeadm certs renew` 更新现有 ECDSA 证书, - 但你不能在集群运行期间或升级期间切换 RSA 和 ECDSA 算法。 - Kubernetes {{< skew currentVersion >}} 有一个错误,尽管开启了特性门控, - 所生成的 kubeconfig 文件中的密钥仍使用 RSA 设置。 - 在 v1.31 之前的 Kubernetes 版本中,即使启用了 `PublicKeysECDSA` 特性门控, - 所生成的 kubeconfig 文件中的密钥仍然被设置为使用 RSA。 +`NodeLocalCRISocket` +: 启用此特性门控后,kubeadm 将使用 `/var/lib/kubelet/instance-config.yaml` 文件读写每个节点的 CRI 套接字, + 不再是从 Node 对象上的 `kubeadm.alpha.kubernetes.io/cri-socket` 注解读取 CRI 套接字, + 也不再将 CRI 套接字写入到 Node 对象的 `kubeadm.alpha.kubernetes.io/cri-socket` 注解。 + 这个新的文件将作为实例配置补丁被应用,之后才会应用其他通过 `--patches` 标志设置的用户管理的补丁。 + 这个新的文件仅包含源自 + [KubeletConfiguration 文件格式](/zh-cn/docs/reference/config-api/kubelet-config.v1beta1/)的字段 + `containerRuntimeEndpoint`。如果升级期间此特性门控被启用,但 `/var/lib/kubelet/instance-config.yaml` + 文件还不存在,kubeadm 将尝试从 `/var/lib/kubelet/kubeadm-flags.env` 文件读取 CRI 套接字值。 `WaitForAllControlPlaneComponents` : 启用此特性门控后,kubeadm 将等待控制平面节点上的所有控制平面组件 - (kube-apiserver、kube-controller-manager、kube-scheduler)在其 `/healthz` - 端点上报告 200 状态码。这些检测在 `https://127.0.0.1:PORT/healthz` 上执行,其中 - `PORT` 取自组件的 `--secure-port` 标志。 + (kube-apiserver、kube-controller-manager、kube-scheduler)在其 `/livez` 或 `/healthz` + 端点上报告 200 状态码。这些检测请求是针对 `https://ADDRESS:PORT/ENDPOINT` 进行的。其中: + + - `PORT` 取自组件的 `--secure-port` 标志。 + - `ADDRESS` 对 kube-apiserver 而言是其 `--advertise-address`,对于 kube-scheduler 和 + kube-controller-manager 而言是其 `--bind-address`。 + - 对于 kube-controller-manager,其 `ENDPOINT` 只能是 `/healthz`,直到它也支持 `/livez` 为止。 + + + 如果你在 kubeadm 配置中指定自定义的 `ADDRESS` 或 `PORT`,kubeadm 将使用这些定制的值。 如果没有启用此特性门控,kubeadm 将仅等待控制平面节点上的 kube-apiserver 准备就绪。 等待过程在 kubeadm 启动主机上的 kubelet 后立即开始。如果你希望在 `kubeadm init` 或 `kubeadm join` 命令执行期间观察所有控制平面组件的就绪状态,建议你启用此特性门控。 @@ -389,12 +405,14 @@ List of deprecated feature gates: {{< table caption="kubeadm deprecated feature gates" >}} Feature | Default | Alpha | Beta | GA | Deprecated :-------|:--------|:------|:-----|:---|:---------- +`PublicKeysECDSA` | `false` | 1.19 | - | - | 1.31 `RootlessControlPlane` | `false` | 1.22 | - | - | 1.31 {{< /table >}} --> {{< table caption="kubeadm 弃用的特性门控" >}} 特性 | 默认值 | Alpha | Beta | GA | 弃用 :-------|:--------|:------|:-----|:---|:---------- +`PublicKeysECDSA` | `false` | 1.19 | - | - | 1.31 `RootlessControlPlane` | `false` | 1.22 | - | - | 1.31 {{< /table >}} @@ -403,12 +421,29 @@ Feature gate descriptions: --> 特性门控描述: + +`PublicKeysECDSA` +: 可用于创建一个使用 ECDSA 证书而非默认 RSA 算法的集群。 + 支持用 `kubeadm certs renew` 更新现有 ECDSA 证书, + 但你不能在集群运行期间或升级期间切换 RSA 和 ECDSA 算法。 + 在 v1.31 之前的 Kubernetes 版本中有一个 Bug,即使你启用了 `PublicKeysECDSA` 特性门控, + 所生成的 kubeconfig 文件中的密钥仍然使用 RSA 设置。 + 此特性门控现已弃用,替换为 kubeadm v1beta4 中可用的 `encryptionAlgorithm` 功能。 + `RootlessControlPlane` : 设置此标志来配置 kubeadm 所部署的控制平面组件中的静态 Pod 容器 @@ -446,7 +481,7 @@ Feature gate descriptions: `IPv6DualStack` : 在 IP 双栈特性处于开发过程中时,此标志有助于配置组件的双栈支持。有关 Kubernetes @@ -455,13 +490,13 @@ dual-stack support see [Dual-stack support with kubeadm](/docs/setup/production- `UnversionedKubeletConfigMap` : 此标志控制 kubeadm 存储 kubelet 配置数据的 {{}} 的名称。 @@ -477,7 +512,8 @@ if that does not succeed, kubeadm falls back to using the legacy (versioned) nam `UpgradeAddonsBeforeControlPlane` : 此特性门控已被移除。它在 v1.28 中作为一个已弃用的特性被引入,在 v1.31 中被移除。 @@ -487,9 +523,11 @@ if that does not succeed, kubeadm falls back to using the legacy (versioned) nam ### Adding kube-proxy parameters {#kube-proxy} For information about kube-proxy parameters in the kubeadm configuration see: + - [kube-proxy reference](/docs/reference/config-api/kube-proxy-config.v1alpha1/) For information about enabling IPVS mode with kubeadm see: + - [IPVS](https://github.com/kubernetes/kubernetes/blob/master/pkg/proxy/ipvs/README.md) --> ### 添加 kube-proxy 参数 {#kube-proxy} @@ -506,6 +544,7 @@ kubeadm 配置中有关 kube-proxy 的说明请查看: ### Passing custom flags to control plane components {#control-plane-flags} For information about passing flags to control plane components see: + - [control-plane-flags](/docs/setup/production-environment/tools/kubeadm/control-plane-flags/) --> ### 向控制平面组件传递自定义的命令行参数 {#control-plane-flags} @@ -517,7 +556,7 @@ For information about passing flags to control plane components see: @@ -591,8 +630,7 @@ can consume, you must: * 使用 `kubeadm config images {list|pull}` 从 `registry.k8s.io` 的默认路径中拉取镜像。 @@ -604,8 +642,7 @@ for etcd and CoreDNS. #### Custom sandbox (pause) images {#custom-pause-image} To set a custom image for these you need to configure this in your -{{< glossary_tooltip text="container runtime" term_id="container-runtime" >}} -to use the image. +{{< glossary_tooltip text="container runtime" term_id="container-runtime" >}} to use the image. Consult the documentation for your container runtime to find out how to change this setting; for selected container runtimes, you can also find advice within the [Container Runtimes](/docs/setup/production-environment/container-runtimes/) topic. @@ -619,13 +656,13 @@ for selected container runtimes, you can also find advice within the 你可以在[容器运行时](/zh-cn/docs/setup/production-environment/container-runtimes/)主题下找到一些建议。 ### 将控制平面证书上传到集群 {#uploading-control-plane-certificates-to-the-cluster} @@ -704,7 +741,7 @@ For further information, see [Managing the kubeadm drop-in file for systemd](/do ### 结合 CRI 运行时使用 kubeadm {#use-kubeadm-with-cri-runtimes} @@ -715,14 +752,14 @@ see the [kubeadm CRI installation guide](/docs/setup/production-environment/tool ### 设置节点的名称 {#setting-the-node-name} -默认情况下,`kubeadm` 基于机器的主机地址分配一个节点名称。你可以使用 `--node-name` 参数覆盖此设置。 +默认情况下,kubeadm 基于机器的主机地址分配一个节点名称。你可以使用 `--node-name` 参数覆盖此设置。 此标识将合适的 [`--hostname-override`](/zh-cn/docs/reference/command-line-tools-reference/kubelet/#options) 值传递给 kubelet。 @@ -738,7 +775,7 @@ Be aware that overriding the hostname can Rather than copying the token you obtained from `kubeadm init` to each node, as in the [basic kubeadm tutorial](/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/), you can parallelize the token distribution for easier automation. To implement this automation, -you must know the IP address that the control-plane node will have after it is started, or use a +you must know the IP address that the control plane node will have after it is started, or use a DNS name or an address of a load balancer. --> ### kubeadm 自动化 {#automating-kubeadm} @@ -749,9 +786,8 @@ DNS name or an address of a load balancer. 要实现自动化,你必须知道控制平面节点启动后将拥有的 IP 地址,或使用 DNS 名称或负载均衡器的地址。 @@ -765,15 +801,15 @@ DNS name or an address of a load balancer. ``` 2. 使用这个令牌同时启动控制平面节点和工作节点。这些节点一旦运行起来应该就会互相寻找对方并且形成集群。 同样的 `--token` 参数可以同时用于 `kubeadm init` 和 `kubeadm join` 命令。 3. 当接入其他控制平面节点时,可以对 `--certificate-key` 执行类似的操作。可以使用以下方式生成密钥: @@ -784,7 +820,7 @@ DNS name or an address of a load balancer. 一旦集群启动起来,你就可以从控制平面节点的 `/etc/kubernetes/admin.conf` 文件获取管理凭证, @@ -796,8 +832,8 @@ a control-plane node to talk to the cluster with administrator credentials or 注意这种搭建集群的方式在安全保证上会有一些宽松,因为这种方式不允许使用 `--discovery-token-ca-cert-hash` 来验证根 CA 的哈希值