Skip to content

Commit 4199797

Browse files
authored
Merge pull request #48080 from qlijin/adding-windows-nodes.md
[zh-cn] sync adding-windows-nodes.md
2 parents 7ad5ab9 + 1b810b1 commit 4199797

File tree

1 file changed

+283
-0
lines changed

1 file changed

+283
-0
lines changed
Lines changed: 283 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,283 @@
1+
---
2+
title: 添加 Windows 工作节点
3+
content_type: task
4+
weight: 11
5+
---
6+
<!--
7+
title: Adding Windows worker nodes
8+
content_type: task
9+
weight: 11
10+
-->
11+
12+
<!-- overview -->
13+
14+
{{< feature-state for_k8s_version="v1.18" state="beta" >}}
15+
16+
<!--
17+
This page explains how to add Windows worker nodes to a kubeadm cluster.
18+
-->
19+
本页介绍如何将 Linux 工作节点添加到 kubeadm 集群。
20+
21+
## {{% heading "prerequisites" %}}
22+
23+
<!--
24+
* A running [Windows Server 2022](https://www.microsoft.com/cloud-platform/windows-server-pricing)
25+
(or higher) instance with administrative access.
26+
* A running kubeadm cluster created by `kubeadm init` and following the steps
27+
in the document [Creating a cluster with kubeadm](/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/).
28+
-->
29+
* 一个正在运行的 [Windows Server 2022](https://www.microsoft.com/cloud-platform/windows-server-pricing)
30+
(或更高版本)实例,且具备管理权限。
31+
* 一个正在运行的、由 `kubeadm init` 命令创建的集群,且集群的创建遵循
32+
[使用 kubeadm 创建集群](/zh-cn/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/)
33+
文档中所给的步骤。
34+
35+
<!-- steps -->
36+
37+
<!--
38+
## Adding Windows worker nodes
39+
-->
40+
## 添加 Windows 工作节点 {#adding-windows-worker-nodes}
41+
42+
{{< note >}}
43+
<!--
44+
To facilitate the addition of Windows worker nodes to a cluster, PowerShell scripts from the repository
45+
https://sigs.k8s.io/sig-windows-tools are used.
46+
-->
47+
为了方便将 Windows 工作节点添加到集群,下面会用到代码仓库
48+
https://sigs.k8s.io/sig-windows-tools 里的 PowerShell 脚本。
49+
{{< /note >}}
50+
51+
<!--
52+
Do the following for each machine:
53+
54+
1. Open a PowerShell session on the machine.
55+
1. Make sure you are Administrator or a privileged user.
56+
57+
Then proceed with the steps outlined below.
58+
59+
### Install containerd
60+
-->
61+
对每台机器执行以下操作:
62+
63+
1. 在机器上打开一个 PowerShell 会话。
64+
1. 确保你是管理员或具有特权的用户。
65+
66+
然后继续执行下面的步骤。
67+
68+
### 安装 Containerd {#install-containerd}
69+
70+
{{% thirdparty-content %}}
71+
72+
<!--
73+
To install containerd, first run the following command:
74+
-->
75+
要安装 Containerd,首先运行以下命令:
76+
77+
```PowerShell
78+
curl.exe -LO https://raw.githubusercontent.com/kubernetes-sigs/sig-windows-tools/master/hostprocess/Install-Containerd.ps1
79+
``````
80+
81+
<!--
82+
Then run the following command, but first replace `CONTAINERD_VERSION` with a recent release
83+
from the [containerd repository](https://github.com/containerd/containerd/releases).
84+
The version must not have a `v` prefix. For example, use `1.7.22` instead of `v1.7.22`:
85+
-->
86+
然后运行以下命令,但要首先将 `CONTAINERD_VERSION` 替换为
87+
[Containerd 仓库](https://github.com/containerd/containerd/releases) 中的最新发布版本。
88+
版本号不能带有前缀 `v` 。例如,使用 `1.7.22` 而不是 `v1.7.22`:
89+
90+
```PowerShell
91+
.\Install-Containerd.ps1 -ContainerDVersion CONTAINERD_VERSION
92+
```
93+
94+
<!--
95+
* Adjust any other parameters for `Install-Containerd.ps1` such as `netAdapterName` as you need them.
96+
* Set `skipHypervisorSupportCheck` if your machine does not support Hyper-V and cannot host Hyper-V isolated
97+
containers.
98+
* If you change the `Install-Containerd.ps1` optional parameters `CNIBinPath` and/or `CNIConfigPath` you will
99+
need to configure the installed Windows CNI plugin with matching values.
100+
-->
101+
* 根据需要调整 `Install-Containerd.ps1` 的所有其他参数,例如 `netAdapterName`
102+
* 如果你的机器不支持 Hyper-V,且无法托管 Hyper-V 的隔离容器,
103+
请设置 `skipHypervisorSupportCheck`
104+
* 如果你要更改 `Install-Containerd.ps1` 中的可选参数 `CNIBinPath` 和/或
105+
`CNIConfigPath`,则需要配置已安装的 Windows CNI 插件,使之与这里的值匹配。
106+
107+
<!--
108+
### Install kubeadm and kubelet
109+
110+
Run the following commands to install kubeadm and the kubelet:
111+
-->
112+
### 安装 kubeadm 和 kubelet {#install-kubeadm-and-kubelet}
113+
114+
运行以下命令安装 kubeadm 和 kubelet:
115+
116+
```PowerShell
117+
curl.exe -LO https://raw.githubusercontent.com/kubernetes-sigs/sig-windows-tools/master/hostprocess/PrepareNode.ps1
118+
.\PrepareNode.ps1 -KubernetesVersion v{{< skew currentVersion >}}
119+
```
120+
121+
<!--
122+
* Adjust the parameter `KubernetesVersion` of `PrepareNode.ps1` if needed.
123+
124+
### Run `kubeadm join`
125+
126+
Run the command that was output by `kubeadm init`. For example:
127+
-->
128+
* 根据需要调整 `PrepareNode.ps1` 中的参数 `KubernetesVersion`
129+
130+
### 运行 `kubeadm join` {#run-kubeadm-join}
131+
132+
运行 `kubeadm init` 所输出的命令。例如:
133+
134+
```bash
135+
kubeadm join --token <token> <control-plane-host>:<control-plane-port> --discovery-token-ca-cert-hash sha256:<hash>
136+
```
137+
138+
<!--
139+
#### Additional information about kubeadm join
140+
-->
141+
#### kubeadm join 的附加信息 {#additional-information-about-kubeadm-join}
142+
143+
{{< note >}}
144+
<!--
145+
To specify an IPv6 tuple for `<control-plane-host>:<control-plane-port>`, IPv6 address must be enclosed in square brackets, for example: `[2001:db8::101]:2073`.
146+
-->
147+
要为 `<control-plane-host>:<control-plane-port>` 指定一个 IPv6 元组,
148+
IPv6 地址必须用方括号括起来,例如:`[2001:db8::101]:2073`
149+
{{< /note >}}
150+
151+
<!--
152+
If you do not have the token, you can get it by running the following command on the control plane node:
153+
-->
154+
如果你没有令牌,可以在控制平面节点上运行以下命令来获取:
155+
156+
<!--
157+
# Run this on a control plane node
158+
-->
159+
```bash
160+
# 在控制平面节点上运行此命令
161+
sudo kubeadm token list
162+
```
163+
164+
<!--
165+
The output is similar to this:
166+
-->
167+
命令输出同以下内容类似:
168+
169+
```console
170+
TOKEN TTL EXPIRES USAGES DESCRIPTION EXTRA GROUPS
171+
8ewj1p.9r9hcjoqgajrj4gi 23h 2018-06-12T02:51:28Z authentication, The default bootstrap system:
172+
signing token generated by bootstrappers:
173+
'kubeadm init'. kubeadm:
174+
default-node-token
175+
```
176+
177+
<!--
178+
By default, node join tokens expire after 24 hours. If you are joining a node to the cluster after the
179+
current token has expired, you can create a new token by running the following command on the
180+
control plane node:
181+
-->
182+
默认情况下,节点加入令牌会在 24 小时后过期。当前令牌过期后,如果想把节点加入集群,
183+
可以在控制平面节点上运行以下命令来创建新令牌:
184+
185+
<!--
186+
# Run this on a control plane node
187+
-->
188+
```bash
189+
# 在控制平面节点上运行此命令
190+
sudo kubeadm token create
191+
```
192+
193+
<!--
194+
The output is similar to this:
195+
-->
196+
命令输出同以下内容类似:
197+
198+
```console
199+
5didvk.d09sbcov8ph2amjw
200+
```
201+
202+
<!--
203+
If you don't have the value of `--discovery-token-ca-cert-hash`, you can get it by running the
204+
following commands on the control plane node:
205+
-->
206+
如果你没有 `--discovery-token-ca-cert-hash` 的具体值,可以在控制平面节点上运行以下命令来获取:
207+
208+
```bash
209+
sudo cat /etc/kubernetes/pki/ca.crt | openssl x509 -pubkey | openssl rsa -pubin -outform der 2>/dev/null | \
210+
openssl dgst -sha256 -hex | sed 's/^.* //'
211+
```
212+
213+
<!--
214+
The output is similar to:
215+
-->
216+
命令输出同以下内容类似:
217+
218+
```console
219+
8cb2de97839780a412b93877f8507ad6c94f73add17d5d7058e91741c9d5ec78
220+
```
221+
222+
<!--
223+
The output of the `kubeadm join` command should look something like:
224+
-->
225+
`kubeadm join` 命令的输出应该同以下内容类似:
226+
227+
```
228+
[preflight] Running pre-flight checks
229+
230+
... (log output of join workflow) ...
231+
232+
Node join complete:
233+
* Certificate signing request sent to control-plane and response
234+
received.
235+
* Kubelet informed of new secure connection details.
236+
237+
Run 'kubectl get nodes' on control-plane to see this machine join.
238+
```
239+
240+
<!--
241+
A few seconds later, you should notice this node in the output from `kubectl get nodes`.
242+
(for example, run `kubectl` on a control plane node).
243+
244+
### Network configuration
245+
246+
CNI setup on clusters mixed with Linux and Windows nodes requires more steps than just
247+
running `kubectl apply` on a manifest file. Additionally, the CNI plugin running on control
248+
plane nodes must be prepared to support the CNI plugin running on Windows worker nodes.
249+
-->
250+
几秒钟后,你应该在 `kubectl get nodes` 的输出中看到该节点。
251+
(例如,可以在控制平面节点上运行 `kubectl`)。
252+
253+
### 网络配置 {#network-configuration}
254+
255+
在混合了 Linux 和 Windows 节点的集群中,CNI 设置所需的步骤不仅仅是对清单文件运行
256+
`kubectl apply`。此外,运行在控制平面节点上的 CNI 插件必须能够支持在 Windows 工作节点上
257+
运行的 CNI 插件。
258+
259+
{{% thirdparty-content %}}
260+
261+
<!--
262+
Only a few CNI plugins currently support Windows. Below you can find individual setup instructions for them:
263+
* [Flannel](https://sigs.k8s.io/sig-windows-tools/guides/flannel.md)
264+
* [Calico](https://docs.tigera.io/calico/latest/getting-started/kubernetes/windows-calico/)
265+
266+
### Install kubectl for Windows (optional) {#install-kubectl}
267+
268+
See [Install and Set Up kubectl on Windows](/docs/tasks/tools/install-kubectl-windows/).
269+
-->
270+
目前只有少数 CNI 插件支持 Windows。以下是它们各自的设置说明:
271+
* [Flannel](https://sigs.k8s.io/sig-windows-tools/guides/flannel.md)
272+
* [Calico](https://docs.tigera.io/calico/latest/getting-started/kubernetes/windows-calico/)
273+
274+
### 在 Windows 上安装 kubectl (可选) {#install-kubectl}
275+
276+
参见 [在 Windows 上安装和设置 kubectl](/zh-cn/docs/tasks/tools/install-kubectl-windows/)
277+
278+
## {{% heading "whatsnext" %}}
279+
280+
<!--
281+
* See how to [add Linux worker nodes](/docs/tasks/administer-cluster/kubeadm/adding-linux-nodes/).
282+
-->
283+
参见如何 [添加 Linux 工作节点](/zh-cn/docs/tasks/administer-cluster/kubeadm/adding-linux-nodes/)

0 commit comments

Comments
 (0)