Skip to content

Commit 72ba847

Browse files
authored
Merge pull request #31178 from tengqm/zh-dual-stack
[zh] Translate dual-stack-support page
2 parents 1e5b3ab + c939f81 commit 72ba847

File tree

1 file changed

+243
-0
lines changed

1 file changed

+243
-0
lines changed
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
---
2+
title: 使用 kubeadm 支持双协议栈
3+
content_type: task
4+
weight: 110
5+
min-kubernetes-server-version: 1.21
6+
---
7+
8+
<!--
9+
title: Dual-stack support with kubeadm
10+
content_type: task
11+
weight: 110
12+
min-kubernetes-server-version: 1.21
13+
-->
14+
15+
<!-- overview -->
16+
17+
{{< feature-state for_k8s_version="v1.23" state="stable" >}}
18+
19+
<!--
20+
Your Kubernetes cluster includes [dual-stack](/docs/concepts/services-networking/dual-stack/) networking, which means that cluster networking lets you use either address family. In a cluster, the control plane can assign both an IPv4 address and an IPv6 address to a single {{< glossary_tooltip text="Pod" term_id="pod" >}} or a {{< glossary_tooltip text="Service" term_id="service" >}}.
21+
-->
22+
你的集群包含[双协议栈](/zh/docs/concepts/services-networking/dual-stack/)组网支持,
23+
这意味着集群网络允许你在两种地址族间任选其一。在集群中,控制面可以为同一个
24+
{{< glossary_tooltip text="Pod" term_id="pod" >}} 或者 {{< glossary_tooltip text="Service" term_id="service" >}}
25+
同时赋予 IPv4 和 IPv6 地址。
26+
27+
<!-- body -->
28+
29+
## {{% heading "prerequisites" %}}
30+
31+
<!--
32+
You need to have installed the {{< glossary_tooltip text="kubeadm" term_id="kubeadm" >}} tool, following the steps from [Installing kubeadm](/docs/setup/production-environment/tools/kubeadm/install-kubeadm/).
33+
-->
34+
你需要已经遵从[安装 kubeadm](/zh/docs/setup/production-environment/tools/kubeadm/install-kubeadm/)
35+
中所给的步骤安装了 {{< glossary_tooltip text="kubeadm" term_id="kubeadm" >}} 工具。
36+
37+
<!--
38+
For each server that you want to use as a {{< glossary_tooltip text="node" term_id="node" >}}, make sure it allows IPv6 forwarding. On Linux, you can set this by running run `sysctl -w net.ipv6.conf.all.forwarding=1` as the root user on each server.
39+
-->
40+
针对你要作为{{< glossary_tooltip text="节点" term_id="node" >}}使用的每台服务器,
41+
确保其允许 IPv6 转发。在 Linux 节点上,你可以通过以 root 用户在每台服务器上运行
42+
`sysctl -w net.ipv6.conf.all.forwarding=1` 来完成设置。
43+
44+
<!--
45+
You need to have an IPv4 and and IPv6 address range to use. Cluster operators typically
46+
use private address ranges for IPv4. For IPv6, a cluster operator typically chooses a global
47+
unicast address block from within `2000::/3`, using a range that is assigned to the operator.
48+
You don't have to route the cluster's IP address ranges to the public internet.
49+
50+
The size of the IP address allocations should be suitable for the number of Pods and
51+
Services that you are planning to run.
52+
-->
53+
你需要一个可以使用的 IPv4 和 IPv6 地址范围。集群操作人员通常为 IPv4 使用
54+
私有地址范围。对于 IPv6,集群操作人员通常会基于分配给该操作人员的地址范围,
55+
`2000::/3` 中选择一个全局的单播地址块。你不需要将集群的 IP 地址范围路由
56+
到公众互联网。
57+
58+
{{< note >}}
59+
<!--
60+
If you are upgrading an existing cluster with the `kubeadm upgrade` command,
61+
`kubeadm` does not support making modifications to the pod IP address range
62+
(“cluster CIDR”) nor to the cluster's Service address range (“Service CIDR”).
63+
-->
64+
如果你在使用 `kubeadm upgrade` 命令升级现有的集群,`kubeadm` 不允许更改 Pod
65+
的 IP 地址范围(“集群 CIDR”),也不允许更改集群的服务地址范围(“Service CIDR”)。
66+
{{< /note >}}
67+
68+
<!--
69+
### Create a dual-stack cluster
70+
71+
To create a dual-stack cluster with `kubeadm init` you can pass command line arguments
72+
similar to the following example:
73+
-->
74+
### 创建双协议栈集群 {#create-a-dual-stack-cluster}
75+
76+
要使用 `kubeadm init` 创建一个双协议栈集群,你可以传递与下面的例子类似的命令行参数:
77+
78+
```shell
79+
# 这里的地址范围仅作示例使用
80+
kubeadm init --pod-network-cidr=10.244.0.0/16,2001:db8:42:0::/56 --service-cidr=10.96.0.0/16,2001:db8:42:1::/112
81+
```
82+
83+
<!--
84+
To make things clearer, here is an example kubeadm [configuration file](https://pkg.go.dev/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3) `kubeadm-config.yaml` for the primary dual-stack control plane node.
85+
-->
86+
为了更便于理解,参看下面的名为 `kubeadm-config.yaml` 的 kubeadm
87+
[配置文件](/docs/reference/config-api/kubeadm-config.v1beta3/)
88+
该文件用于双协议栈控制面的主控制节点。
89+
90+
```yaml
91+
---
92+
apiVersion: kubeadm.k8s.io/v1beta3
93+
kind: ClusterConfiguration
94+
networking:
95+
podSubnet: 10.244.0.0/16,2001:db8:42:0::/56
96+
serviceSubnet: 10.96.0.0/16,2001:db8:42:1::/112
97+
---
98+
apiVersion: kubeadm.k8s.io/v1beta3
99+
kind: InitConfiguration
100+
localAPIEndpoint:
101+
advertiseAddress: "10.100.0.1"
102+
bindPort: 6443
103+
nodeRegistration:
104+
kubeletExtraArgs:
105+
node-ip: 10.100.0.2,fd00:1:2:3::2
106+
```
107+
108+
<!--
109+
`advertiseAddress` in InitConfiguration specifies the IP address that the API Server will advertise it is listening on. The value of `advertiseAddress` equals the `--apiserver-advertise-address` flag of `kubeadm init`
110+
111+
Run kubeadm to initiate the dual-stack control plane node:
112+
-->
113+
InitConfiguration 中的 `advertiseAddress` 给出 API 服务器将公告自身要监听的
114+
IP 地址。`advertiseAddress` 的取值与 `kubeadm init` 的标志
115+
`--apiserver-advertise-address` 的取值相同。
116+
117+
运行 kubeadm 来实例化双协议栈控制面节点:
118+
119+
```shell
120+
kubeadm init --config=kubeadm-config.yaml
121+
```
122+
123+
<!--
124+
The kube-controller-manager flags `--node-cidr-mask-size-ipv4|--node-cidr-mask-size-ipv6` are set with default values. See [configure IPv4/IPv6 dual stack](/docs/concepts/services-networking/dual-stack#configure-ipv4-ipv6-dual-stack).
125+
-->
126+
kube-controller-manager 标志 `--node-cidr-mask-size-ipv4|--node-cidr-mask-size-ipv6`
127+
是使用默认值来设置的。参见[配置 IPv4/IPv6 双协议栈](/zh/docs/concepts/services-networking/dual-stack#configure-ipv4-ipv6-dual-stack)。
128+
129+
{{< note >}}
130+
<!--
131+
The `--apiserver-advertise-address` flag does not support dual-stack.
132+
-->
133+
标志 `--apiserver-advertise-address` 不支持双协议栈。
134+
{{< /note >}}
135+
136+
<!--
137+
### Join a node to dual-stack cluster
138+
139+
Before joining a node, make sure that the node has IPv6 routable network interface and allows IPv6 forwarding.
140+
141+
Here is an example kubeadm [configuration file](https://pkg.go.dev/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3) `kubeadm-config.yaml` for joining a worker node to the cluster.
142+
-->
143+
### 向双协议栈集群添加节点 {#join-a-node-to-dual-stack-cluster}
144+
145+
在添加节点之前,请确保该节点具有 IPv6 可路由的网络接口并且启用了 IPv6 转发。
146+
147+
下面的名为 `kubeadm-config.yaml` 的 kubeadm
148+
[配置文件](/docs/reference/config-api/kubeadm-config.v1beta3/)
149+
示例用于向集群中添加工作节点。
150+
151+
```yaml
152+
apiVersion: kubeadm.k8s.io/v1beta3
153+
kind: JoinConfiguration
154+
discovery:
155+
bootstrapToken:
156+
apiServerEndpoint: 10.100.0.1:6443
157+
token: "clvldh.vjjwg16ucnhp94qr"
158+
caCertHashes:
159+
- "sha256:a4863cde706cfc580a439f842cc65d5ef112b7b2be31628513a9881cf0d9fe0e"
160+
# 请更改上面的认证信息,使之与你的集群中实际使用的令牌和 CA 证书匹配
161+
nodeRegistration:
162+
kubeletExtraArgs:
163+
node-ip: 10.100.0.3,fd00:1:2:3::3
164+
```
165+
166+
<!--
167+
Also, here is an example kubeadm [configuration file](https://pkg.go.dev/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3) `kubeadm-config.yaml` for joining another control plane node to the cluster.
168+
-->
169+
下面的名为 `kubeadm-config.yaml` 的 kubeadm
170+
[配置文件](/docs/reference/config-api/kubeadm-config.v1beta3/)
171+
示例用于向集群中添加另一个控制面节点。
172+
173+
```yaml
174+
apiVersion: kubeadm.k8s.io/v1beta3
175+
kind: JoinConfiguration
176+
controlPlane:
177+
localAPIEndpoint:
178+
advertiseAddress: "10.100.0.2"
179+
bindPort: 6443
180+
discovery:
181+
bootstrapToken:
182+
apiServerEndpoint: 10.100.0.1:6443
183+
token: "clvldh.vjjwg16ucnhp94qr"
184+
caCertHashes:
185+
- "sha256:a4863cde706cfc580a439f842cc65d5ef112b7b2be31628513a9881cf0d9fe0e"
186+
# 请更改上面的认证信息,使之与你的集群中实际使用的令牌和 CA 证书匹配
187+
nodeRegistration:
188+
kubeletExtraArgs:
189+
node-ip: 10.100.0.4,fd00:1:2:3::4
190+
```
191+
192+
<!--
193+
`advertiseAddress` in JoinConfiguration.controlPlane specifies the IP address that the API Server will advertise it is listening on. The value of `advertiseAddress` equals the `--apiserver-advertise-address` flag of `kubeadm join`.
194+
-->
195+
JoinConfiguration.controlPlane 中的 `advertiseAddress` 设定 API 服务器将公告自身要监听的
196+
IP 地址。`advertiseAddress` 的取值与 `kubeadm join` 的标志
197+
`--apiserver-advertise-address` 的取值相同。
198+
199+
```shell
200+
kubeadm join --config=kubeadm-config.yaml
201+
```
202+
203+
<!--
204+
### Create a single-stack cluster
205+
-->
206+
### 创建单协议栈集群 {#create-a-single-stack-cluster}
207+
208+
{{< note >}}
209+
<!--
210+
Dual-stack support doesn't mean that you need to use dual-stack addressing.
211+
You can deploy a single-stack cluster that has the dual-stack networking feature enabled.
212+
-->
213+
双协议栈支持并不意味着你需要使用双协议栈来寻址。
214+
你可以部署一个启用了双协议栈联网特性的单协议栈集群。
215+
{{< /note >}}
216+
217+
<!--
218+
To make things more clear, here is an example kubeadm [configuration file](https://pkg.go.dev/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3) `kubeadm-config.yaml` for the single-stack control plane node.
219+
-->
220+
为了更便于理解,参看下面的名为 `kubeadm-config.yaml` 的 kubeadm
221+
[配置文件](/docs/reference/config-api/kubeadm-config.v1beta3/)示例,
222+
该文件用于单协议栈控制面节点。
223+
224+
225+
```yaml
226+
apiVersion: kubeadm.k8s.io/v1beta3
227+
kind: ClusterConfiguration
228+
networking:
229+
podSubnet: 10.244.0.0/16
230+
serviceSubnet: 10.96.0.0/16
231+
```
232+
233+
## {{% heading "whatsnext" %}}
234+
235+
<!--
236+
* [Validate IPv4/IPv6 dual-stack](/docs/tasks/network/validate-dual-stack) networking
237+
* Read about [Dual-stack](/docs/concepts/services-networking/dual-stack/) cluster networking
238+
* Learn more about the kubeadm [configuration format](/docs/reference/config-api/kubeadm-config.v1beta3/)
239+
-->
240+
* [验证 IPv4/IPv6 双协议栈](/zh/docs/tasks/network/validate-dual-stack)联网
241+
* 阅读[双协议栈](/zh/docs/concepts/services-networking/dual-stack/)集群网络
242+
* 进一步了解 kubeadm [配置格式](/docs/reference/config-api/kubeadm-config.v1beta3/)
243+

0 commit comments

Comments
 (0)