[zh] Sync changes from English site (12)

This commit is contained in:
Qiming Teng
2020-11-23 13:10:33 +08:00
parent fd65678baa
commit 81bc52053d
15 changed files with 438 additions and 313 deletions
@@ -1,7 +1,4 @@
---
reviewers:
- lachie83
- khenidak
title: 验证 IPv4/IPv6 双协议栈
content_type: task
---
@@ -17,7 +14,7 @@ content_type: task
<!--
This document shares how to validate IPv4/IPv6 dual-stack enabled Kubernetes clusters.
-->
这篇文章分享了如何验证 IPv4/IPv6 双协议栈的 Kubernetes 集群。
本文分享了如何验证 IPv4/IPv6 双协议栈的 Kubernetes 集群。
## {{% heading "prerequisites" %}}
@@ -25,14 +22,14 @@ This document shares how to validate IPv4/IPv6 dual-stack enabled Kubernetes clu
* Kubernetes 1.16 or later
* Provider support for dual-stack networking (Cloud provider or otherwise must be able to provide Kubernetes nodes with routable IPv4/IPv6 network interfaces)
* Kubenet network plugin
* Kube-proxy running in mode IPVS
* [Dual-stack enabled](/docs/concepts/services-networking/dual-stack/) cluster
-->
* Kubernetes 1.16 或更高版本
* 提供程序对双协议栈网络的支持 (云供应商或其他方式必须能够为 Kubernetes 节点提供可路由的 IPv4/IPv6 网络接口)
* 一个能够支持双协议栈的[网络插件](/zh/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/)
* 提供程序对双协议栈网络的支持 (云供应商或其他方式必须能够为 Kubernetes 节点
提供可路由的 IPv4/IPv6 网络接口)
* 一个能够支持双协议栈的
[网络插件](/zh/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/)
(如 kubenet 或 Calico)。
* Kube-proxy 在 IPVS 模式下运行
* [启用双协议栈](/zh/docs/concepts/services-networking/dual-stack/) 集群
<!-- steps -->
@@ -89,7 +86,8 @@ Validate that a Pod has an IPv4 and IPv6 address assigned. (replace the Pod name
-->
### 验证 Pod 寻址
验证 Pod 已分配了 IPv4 和 IPv6 地址。(用集群中的有效 Pod 替换 Pod 名称。在此示例中, Pod 名称为 pod01)
验证 Pod 已分配了 IPv4 和 IPv6 地址。(用集群中的有效 Pod 替换 Pod 名称。
在此示例中, Pod 名称为 pod01)
```shell
kubectl get pods pod01 -o go-template --template='{{range .status.podIPs}}{{printf "%s \n" .ip}}{{end}}'
@@ -103,20 +101,22 @@ a00:100::4
<!--
You can also validate Pod IPs using the Downward API via the `status.podIPs` fieldPath. The following snippet demonstrates how you can expose the Pod IPs via an environment variable called `MY_POD_IPS` within a container.
-->
也可以通过 `status.podIPs` 使用 Downward API 验证 Pod IP。以下代码段演示了如何通过容器内称为 `MY_POD_IPS` 的环境变量公开 Pod 的 IP 地址。
也可以通过 `status.podIPs` 使用 Downward API 验证 Pod IP。
以下代码段演示了如何通过容器内称为 `MY_POD_IPS` 的环境变量公开 Pod 的 IP 地址。
```
env:
- name: MY_POD_IPS
valueFrom:
fieldRef:
fieldPath: status.podIPs
```yaml
env:
- name: MY_POD_IPS
valueFrom:
fieldRef:
fieldPath: status.podIPs
```
<!--
The following command prints the value of the `MY_POD_IPS` environment variable from within a container. The value is a comma separated list that corresponds to the Pod's IPv4 and IPv6 addresses.
-->
使用以下命令打印出容器内部 `MY_POD_IPS` 环境变量的值。该值是一个逗号分隔的列表,与 Pod 的 IPv4 和 IPv6 地址相对应。
使用以下命令打印出容器内部 `MY_POD_IPS` 环境变量的值。
该值是一个逗号分隔的列表,与 Pod 的 IPv4 和 IPv6 地址相对应。
```shell
kubectl exec -it pod01 -- set | grep MY_POD_IPS
@@ -129,7 +129,9 @@ MY_POD_IPS=10.244.1.4,a00:100::4
<!--
The Pod's IP addresses will also be written to `/etc/hosts` within a container. The following command executes a cat on `/etc/hosts` on a dual stack Pod. From the output you can verify both the IPv4 and IPv6 IP address for the Pod.
-->
Pod 的 IP 地址也将被写入容器内的 `/etc/hosts` 文件中。在双栈 Pod 上执行 cat `/etc/hosts` 命令操作。从输出结果中,您可以验证 Pod 的 IPv4 和 IPv6 地址。
Pod 的 IP 地址也将被写入容器内的 `/etc/hosts` 文件中。
在双栈 Pod 上执行 cat `/etc/hosts` 命令操作。
从输出结果中,你可以验证 Pod 的 IPv4 和 IPv6 地址。
```shell
kubectl exec -it pod01 -- cat /etc/hosts
@@ -155,15 +157,17 @@ Create the following Service without the `ipFamily` field set. When this field i
## 验证服务
在不设置 `ipFamily` 字段的情况下创建以下服务。
如果未设置此字段,则服务会通过 kube-controller-manager 上的 `--service-cluster-ip-range` 标志从第一个配置的范围中获取 IP。
如果未设置此字段,则服务会通过 kube-controller-manager 上的
`--service-cluster-ip-range` 标志从第一个配置的范围中获取 IP。
{{< codenew file="service/networking/dual-stack-default-svc.yaml" >}}
<!--
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.
-->
通过查看该服务的 YAML 可以观察到该服务的 `ipFamily` 字段已设置为反映通过
kube-controller-manager `--service-cluster-ip-range` 标志设置的第一个配置范围的地址族。
通过查看该服务的 YAML 可以观察到该服务的 `ipFamily` 字段已设置
其取值反映的是通过 kube-controller-manager 的 `--service-cluster-ip-range`
标志所设置的第一个地址范围的地址族。
```shell
kubectl get svc my-service -o yaml
@@ -207,9 +211,12 @@ Create the following Service with the `ipFamily` field set to `IPv6`.
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.
-->
验证服务是否是 IPv6 地址块获取集群 IP 地址。
然后,可以通过 IP 和端口验证对服务的访问。
然后,可以通过 IP 和端口验证对服务的访问。
```shell
kubectl get svc -l app=MyApp
```
```
kubectl get svc -l app=MyApp
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
my-service ClusterIP fe80:20d::d06b <none> 80/TCP 9s
```
@@ -221,7 +228,8 @@ If the cloud provider supports the provisioning of IPv6 enabled external load ba
-->
### 创建双协议栈负载均衡服务
如果云提供商支持配置启用 IPv6 的外部负载均衡器,则将 `ipFamily` 字段设置为 `IPv6` 并将 `type` 字段设置为 `LoadBalancer`的方式创建以下服务
如果云提供商支持配置启用 IPv6 的外部负载均衡器,则将 `ipFamily` 字段设置为
`IPv6` 并将 `type` 字段设置为 `LoadBalancer` 的方式创建以下服务:
{{< codenew file="service/networking/dual-stack-ipv6-lb-svc.yaml" >}}
@@ -229,9 +237,12 @@ If the cloud provider supports the provisioning of IPv6 enabled external load ba
Validate that the Service receives a `CLUSTER-IP` address from the IPv6 address block along with an `EXTERNAL-IP`. You may then validate access to the service via the IP and port.
-->
验证服务是否从 IPv6 地址块中接收到 `CLUSTER-IP` 地址以及 `EXTERNAL-IP`
然后,可以通过 IP 和端口验证对服务的访问。
然后,可以通过 IP 和端口验证对服务的访问。
```shell
kubectl get svc -l app=MyApp
```
```
kubectl get svc -l app=MyApp
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
my-service ClusterIP fe80:20d::d06b 2001:db8:f100:4002::9d37:c0d7 80:31868/TCP 30s
```