Skip to content

Commit 55426e8

Browse files
authored
Merge pull request #26159 from howieyuen/dual-stack
[zh] resync content/zh/docs/tasks/network/validate-dual-stack.md
2 parents 01d8c0a + 70842f2 commit 55426e8

File tree

1 file changed

+110
-24
lines changed

1 file changed

+110
-24
lines changed

content/zh/docs/tasks/network/validate-dual-stack.md

Lines changed: 110 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: 验证 IPv4/IPv6 双协议栈
3+
min-kubernetes-server-version: v1.20
34
content_type: task
45
---
56
<!--
@@ -150,42 +151,45 @@ a00:100::4 pod01
150151
<!--
151152
## Validate Services
152153
153-
Create the following Service without the `ipFamily` field set. When this field is not set, the Service gets an IP from the first configured range via `--service-cluster-ip-range` flag on the kube-controller-manager.
154+
Create the following Service that does not explicitly define `.spec.ipFamilyPolicy`. Kubernetes will assign a cluster IP for the Service from the first configured `service-cluster-ip-range` and set the `.spec.ipFamilyPolicy` to `SingleStack`.
154155
-->
155156
## 验证服务
156157

157-
在不设置 `ipFamily` 字段的情况下创建以下服务
158-
如果未设置此字段,则服务会通过 kube-controller-manager 上的
159-
`--service-cluster-ip-range` 标志从第一个配置的范围中获取 IP
158+
创建以下未显式定义 `.spec.ipFamilyPolicy` 的 Service
159+
Kubernetes 将从首个配置的 `service-cluster-ip-range` 给 Service 分配集群 IP,
160+
并将 `.spec.ipFamilyPolicy` 设置为 `SingleStack`
160161

161162
{{< codenew file="service/networking/dual-stack-default-svc.yaml" >}}
162163

163-
<!--
164-
By viewing the YAML for the Service you can observe that the Service has the `ipFamily` field has set to reflect the address family of the first configured range set via `--service-cluster-ip-range` flag on kube-controller-manager.
164+
<!--
165+
Use `kubectl` to view the YAML for the Service.
165166
-->
166-
通过查看该服务的 YAML ,你可以观察到该服务的 `ipFamily` 字段已被设置。
167-
其取值反映的是通过 kube-controller-manager 的 `--service-cluster-ip-range`
168-
标志所设置的第一个地址范围的地址族。
167+
使用 `kubectl` 查看 Service 的 YAML 定义。
169168

170169
```shell
171170
kubectl get svc my-service -o yaml
172171
```
173172

173+
<!--
174+
The Service has `.spec.ipFamilyPolicy` set to `SingleStack` and `.spec.clusterIP` set to an IPv4 address from the first configured range set via `--service-cluster-ip-range` flag on kube-controller-manager.
175+
-->
176+
该 Service 通过在 kube-controller-manager 的 `--service-cluster-ip-range`
177+
标志设置的第一个配置范围,将 `.spec.ipFamilyPolicy` 设置为 `SingleStack`
178+
`.spec.clusterIP` 设置为 IPv4 地址。
179+
174180
```yaml
175181
apiVersion: v1
176182
kind: Service
177183
metadata:
178-
creationTimestamp: "2019-09-03T20:45:13Z"
179-
labels:
180-
app: MyApp
181184
name: my-service
182185
namespace: default
183-
resourceVersion: "485836"
184-
selfLink: /api/v1/namespaces/default/services/my-service
185-
uid: b6fa83ef-fe7e-47a3-96a1-ac212fa5b030
186186
spec:
187-
clusterIP: 10.0.29.179
188-
ipFamily: IPv4
187+
clusterIP: 10.0.217.164
188+
clusterIPs:
189+
- 10.0.217.164
190+
ipFamilies:
191+
- IPv4
192+
ipFamilyPolicy: SingleStack
189193
ports:
190194
- port: 80
191195
protocol: TCP
@@ -199,25 +203,107 @@ status:
199203
```
200204
201205
<!--
202-
Create the following Service with the `ipFamily` field set to `IPv6`.
206+
Create the following Service that explicitly defines `IPv6` as the first array element in `.spec.ipFamilies`. Kubernetes will assign a cluster IP for the Service from the IPv6 range configured `service-cluster-ip-range` and set the `.spec.ipFamilyPolicy` to `SingleStack`.
203207
-->
204-
在 `ipFamily` 字段设置为 `IPv6` 的情况下创建一下服务。
208+
创建以下显示定义 `.spec.ipFamilies` 数组中的第一个元素为 IPv6 的 Service。
209+
Kubernetes 将 `service-cluster-ip-range` 配置的 IPv6 地址范围给 Service 分配集群 IP,
210+
并将 `.spec.ipFamilyPolicy` 设置为 `SingleStack`。
205211

206212
{{< codenew file="service/networking/dual-stack-ipv6-svc.yaml" >}}
207213

208-
<!--
209-
Validate that the Service gets a cluster IP address from the IPv6 address block. You may then validate access to the service via the IP and port.
214+
<!--
215+
Use `kubectl` to view the YAML for the Service.
210216
-->
211-
验证服务是否是 IPv6 地址块获取集群 IP 地址。
212-
然后,你可以通过 IP 和端口验证对服务的访问。
217+
使用 `kubectl` 查看 Service 的 YAML 定义。
213218

214219
```shell
215-
kubectl get svc -l app=MyApp
220+
kubectl get svc my-service -o yaml
216221
```
222+
223+
<!--
224+
The Service has `.spec.ipFamilyPolicy` set to `SingleStack` and `.spec.clusterIP` set to an IPv6 address from the IPv6 range set via `--service-cluster-ip-range` flag on kube-controller-manager.
225+
-->
226+
该 Service 通过在 kube-controller-manager 的 `--service-cluster-ip-range`
227+
标志设置的 IPv6 地址范围,将 `.spec.ipFamilyPolicy` 设置为 `SingleStack`,
228+
将 `.spec.clusterIP` 设置为 IPv6 地址。
229+
230+
```yaml
231+
apiVersion: v1
232+
kind: Service
233+
metadata:
234+
labels:
235+
app: MyApp
236+
name: my-service
237+
spec:
238+
clusterIP: fd00::5118
239+
clusterIPs:
240+
- fd00::5118
241+
ipFamilies:
242+
- IPv6
243+
ipFamilyPolicy: SingleStack
244+
ports:
245+
- port: 80
246+
protocol: TCP
247+
targetPort: 80
248+
selector:
249+
app: MyApp
250+
sessionAffinity: None
251+
type: ClusterIP
252+
status:
253+
loadBalancer: {}
217254
```
255+
256+
<!--
257+
Create the following Service that explicitly defines `PreferDualStack` in `.spec.ipFamilyPolicy`. Kubernetes will assign both IPv4 and IPv6 addresses (as this cluster has dual-stack enabled) and select the `.spec.ClusterIP` from the list of `.spec.ClusterIPs` based on the address family of the first element in the `.spec.ipFamilies` array.
258+
-->
259+
创建以下显式定义 `.spec.ipFamilyPolicy` 为 `PreferDualStack` 的 Service。
260+
Kubernetes 将分配 IPv4 和 IPv6 地址(因为该集群启用了双栈),
261+
并根据 `.spec.ipFamilies` 数组中第一个元素的地址族,
262+
从 `.spec.ClusterIPs` 列表中选择 `.spec.ClusterIP`。
263+
264+
{{< codenew file="service/networking/dual-stack-preferred-svc.yaml" >}}
265+
266+
{{< note >}}
267+
<!--
268+
The `kubectl get svc` command will only show the primary IP in the `CLUSTER-IP` field.
269+
-->
270+
`kubectl get svc` 命令将仅在 `CLUSTER-IP` 字段中显示主 IP。
271+
272+
```shell
273+
kubectl get svc -l app=MyApp
274+
218275
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
219276
my-service ClusterIP fe80:20d::d06b <none> 80/TCP 9s
220277
```
278+
{{< /note >}}
279+
280+
<!--
281+
Validate that the Service gets cluster IPs from the IPv4 and IPv6 address blocks using `kubectl describe`. You may then validate access to the service via the IPs and ports.
282+
-->
283+
使用 `kubectl describe` 验证服务是否从 IPv4 和 IPv6 地址块中获取了集群 IP。
284+
然后你就可以通过 IP 和端口,验证对服务的访问。
285+
286+
```shell
287+
kubectl describe svc -l app=MyApp
288+
```
289+
290+
```
291+
Name: my-service
292+
Namespace: default
293+
Labels: app=MyApp
294+
Annotations: <none>
295+
Selector: app=MyApp
296+
Type: ClusterIP
297+
IP Family Policy: PreferDualStack
298+
IP Families: IPv4,IPv6
299+
IP: 10.0.216.242
300+
IPs: 10.0.216.242,fd00::af55
301+
Port: <unset> 80/TCP
302+
TargetPort: 9376/TCP
303+
Endpoints: <none>
304+
Session Affinity: None
305+
Events: <none>
306+
```
221307
222308
<!--
223309
### Create a dual-stack load balanced Service

0 commit comments

Comments
 (0)