[zh] Resync concepts file (concepts-3) after lang name change

This commit is contained in:
Qiming Teng
2022-06-12 20:52:40 +08:00
parent 89a4ec69d2
commit fda7e0c9d1
@@ -9,18 +9,17 @@ weight: 70
--- ---
<!-- <!--
reviewers:
- lachie83
- khenidak
- aramase
- bridgetkromhout
title: IPv4/IPv6 dual-stack title: IPv4/IPv6 dual-stack
feature: feature:
title: IPv4/IPv6 dual-stack title: IPv4/IPv6 dual-stack
description: > description: >
Allocation of IPv4 and IPv6 addresses to Pods and Services Allocation of IPv4 and IPv6 addresses to Pods and Services
content_type: concept content_type: concept
reviewers:
- lachie83
- khenidak
- aramase
- bridgetkromhout
weight: 70 weight: 70
--> -->
@@ -29,14 +28,16 @@ weight: 70
{{< feature-state for_k8s_version="v1.23" state="stable" >}} {{< feature-state for_k8s_version="v1.23" state="stable" >}}
<!-- <!--
IPv4/IPv6 dual-stack networking enables the allocation of both IPv4 and IPv6 addresses to {{< glossary_tooltip text="Pods" term_id="pod" >}} and {{< glossary_tooltip text="Services" term_id="service" >}}. IPv4/IPv6 dual-stack networking enables the allocation of both IPv4 and IPv6 addresses to
{{< glossary_tooltip text="Pods" term_id="pod" >}} and {{< glossary_tooltip text="Services" term_id="service" >}}.
--> -->
IPv4/IPv6 双协议栈网络能够将 IPv4 和 IPv6 地址分配给 IPv4/IPv6 双协议栈网络能够将 IPv4 和 IPv6 地址分配给
{{< glossary_tooltip text="Pod" term_id="pod" >}} 和 {{< glossary_tooltip text="Pod" term_id="pod" >}} 和
{{< glossary_tooltip text="Service" term_id="service" >}}。 {{< glossary_tooltip text="Service" term_id="service" >}}。
<!-- <!--
IPv4/IPv6 dual-stack networking is enabled by default for your Kubernetes cluster starting in 1.21, allowing the simultaneous assignment of both IPv4 and IPv6 addresses. IPv4/IPv6 dual-stack networking is enabled by default for your Kubernetes cluster starting in
1.21, allowing the simultaneous assignment of both IPv4 and IPv6 addresses.
--> -->
从 1.21 版本开始,Kubernetes 集群默认启用 IPv4/IPv6 双协议栈网络, 从 1.21 版本开始,Kubernetes 集群默认启用 IPv4/IPv6 双协议栈网络,
以支持同时分配 IPv4 和 IPv6 地址。 以支持同时分配 IPv4 和 IPv6 地址。
@@ -54,9 +55,9 @@ IPv4/IPv6 dual-stack on your Kubernetes cluster provides the following features:
Kubernetes 集群的 IPv4/IPv6 双协议栈可提供下面的功能: Kubernetes 集群的 IPv4/IPv6 双协议栈可提供下面的功能:
<!-- <!--
* Dual-stack Pod networking (a single IPv4 and IPv6 address assignment per Pod) * Dual-stack Pod networking (a single IPv4 and IPv6 address assignment per Pod)
* IPv4 and IPv6 enabled Services * IPv4 and IPv6 enabled Services
* Pod off-cluster egress routing (eg. the Internet) via both IPv4 and IPv6 interfaces * Pod off-cluster egress routing (eg. the Internet) via both IPv4 and IPv6 interfaces
--> -->
* 双协议栈 pod 网络 (每个 pod 分配一个 IPv4 和 IPv6 地址) * 双协议栈 pod 网络 (每个 pod 分配一个 IPv4 和 IPv6 地址)
* IPv4 和 IPv6 启用的服务 * IPv4 和 IPv6 启用的服务
@@ -73,18 +74,20 @@ The following prerequisites are needed in order to utilize IPv4/IPv6 dual-stack
为了使用 IPv4/IPv6 双栈的 Kubernetes 集群,需要满足以下先决条件: 为了使用 IPv4/IPv6 双栈的 Kubernetes 集群,需要满足以下先决条件:
<!-- <!--
* Kubernetes 1.20 or later * Kubernetes 1.20 or later
For information about using dual-stack services with earlier For information about using dual-stack services with earlier
Kubernetes versions, refer to the documentation for that version Kubernetes versions, refer to the documentation for that version
of Kubernetes. of Kubernetes.
* Provider support for dual-stack networking (Cloud provider or otherwise must be able to provide Kubernetes nodes with routable IPv4/IPv6 network interfaces) * Provider support for dual-stack networking (Cloud provider or otherwise must be able to provide
* A [network plugin](/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/) that supports dual-stack networking. Kubernetes nodes with routable IPv4/IPv6 network interfaces)
* A [network plugin](/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/) that
supports dual-stack networking.
--> -->
* Kubernetes 1.20 版本或更高版本,有关更早 Kubernetes 版本的使用双栈服务的信息, * Kubernetes 1.20 版本或更高版本,有关更早 Kubernetes 版本的使用双栈服务的信息,
请参考对应版本的 Kubernetes 文档。 请参考对应版本的 Kubernetes 文档。
* 提供商支持双协议栈网络(云提供商或其他提供商必须能够为 Kubernetes * 提供商支持双协议栈网络(云提供商或其他提供商必须能够为 Kubernetes
节点提供可路由的 IPv4/IPv6 网络接口) 节点提供可路由的 IPv4/IPv6 网络接口)
* 支持双协议栈的[网络插件](/zh/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/) * 支持双协议栈的[网络插件](/zh-cn/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/)
<!-- <!--
## Configure IPv4/IPv6 dual-stack ## Configure IPv4/IPv6 dual-stack
@@ -96,29 +99,29 @@ To configure IPv4/IPv6 dual-stack, set dual-stack cluster network assignments:
--> -->
如果配置 IPv4/IPv6 双栈,请分配双栈集群网络: 如果配置 IPv4/IPv6 双栈,请分配双栈集群网络:
<!-- <!--
* kube-apiserver: * kube-apiserver:
* `--service-cluster-ip-range=<IPv4 CIDR>,<IPv6 CIDR>` * `--service-cluster-ip-range=<IPv4 CIDR>,<IPv6 CIDR>`
* kube-controller-manager: * kube-controller-manager:
* `--cluster-cidr=<IPv4 CIDR>,<IPv6 CIDR>` * `--cluster-cidr=<IPv4 CIDR>,<IPv6 CIDR>`
* `--service-cluster-ip-range=<IPv4 CIDR>,<IPv6 CIDR>` * `--service-cluster-ip-range=<IPv4 CIDR>,<IPv6 CIDR>`
* `--node-cidr-mask-size-ipv4|--node-cidr-mask-size-ipv6` defaults to /24 for IPv4 and /64 for IPv6 * `--node-cidr-mask-size-ipv4|--node-cidr-mask-size-ipv6` defaults to /24 for IPv4 and /64 for IPv6
* kube-proxy: * kube-proxy:
* `--cluster-cidr=<IPv4 CIDR>,<IPv6 CIDR>` * `--cluster-cidr=<IPv4 CIDR>,<IPv6 CIDR>`
* kubelet: * kubelet:
* when there is no `--cloud-provider` the administrator can pass a comma-separated pair * when there is no `--cloud-provider` the administrator can pass a comma-separated pair of IP
of IP addresses via `--node-ip` to manually configure dual-stack `.status.addresses` addresses via `--node-ip` to manually configure dual-stack `.status.addresses` for that Node.
for that Node. If a Pod runs on that node in HostNetwork mode, the Pod reports these IP addresses in its
If a Pod runs on that node in HostNetwork mode, the Pod reports these IP addresses in its `.status.podIPs` field.
`.status.podIPs` field. All `podIPs` in a node match the IP family preference defined by the `.status.addresses`
All `podIPs` in a node match the IP family preference defined by the field for that Node.
`.status.addresses` field for that Node.
--> -->
* kube-apiserver: * kube-apiserver:
* `--service-cluster-ip-range=<IPv4 CIDR>,<IPv6 CIDR>` * `--service-cluster-ip-range=<IPv4 CIDR>,<IPv6 CIDR>`
* kube-controller-manager: * kube-controller-manager:
* `--cluster-cidr=<IPv4 CIDR>,<IPv6 CIDR>` * `--cluster-cidr=<IPv4 CIDR>,<IPv6 CIDR>`
* `--service-cluster-ip-range=<IPv4 CIDR>,<IPv6 CIDR>` * `--service-cluster-ip-range=<IPv4 CIDR>,<IPv6 CIDR>`
* `--node-cidr-mask-size-ipv4|--node-cidr-mask-size-ipv6` 对于 IPv4 默认为 /24对于 IPv6 默认为 /64 * `--node-cidr-mask-size-ipv4|--node-cidr-mask-size-ipv6` 对于 IPv4 默认为 /24
对于 IPv6 默认为 /64
* kube-proxy: * kube-proxy:
* `--cluster-cidr=<IPv4 CIDR>,<IPv6 CIDR>` * `--cluster-cidr=<IPv4 CIDR>,<IPv6 CIDR>`
* kubelet: * kubelet:
@@ -131,7 +134,8 @@ To configure IPv4/IPv6 dual-stack, set dual-stack cluster network assignments:
<!-- <!--
An example of an IPv4 CIDR: `10.244.0.0/16` (though you would supply your own address range) An example of an IPv4 CIDR: `10.244.0.0/16` (though you would supply your own address range)
An example of an IPv6 CIDR: `fdXY:IJKL:MNOP:15::/64` (this shows the format but is not a valid address - see [RFC 4193](https://tools.ietf.org/html/rfc4193)) An example of an IPv6 CIDR: `fdXY:IJKL:MNOP:15::/64` (this shows the format but is not a valid
address - see [RFC 4193](https://tools.ietf.org/html/rfc4193))
--> -->
IPv4 CIDR 的一个例子:`10.244.0.0/16`(尽管你会提供你自己的地址范围)。 IPv4 CIDR 的一个例子:`10.244.0.0/16`(尽管你会提供你自己的地址范围)。
@@ -142,31 +146,35 @@ IPv6 CIDR 的一个例子:`fdXY:IJKL:MNOP:15::/64`
<!-- <!--
## Services ## Services
--> -->
## 服务 ## 服务 {#services}
<!-- <!--
You can create {{< glossary_tooltip text="Services" term_id="service" >}} which can use IPv4, IPv6, or both. You can create {{< glossary_tooltip text="Services" term_id="service" >}} which can use IPv4, IPv6, or both.
The address family of a Service defaults to the address family of the first service cluster IP range (configured via the `--service-cluster-ip-range` flag to the kube-apiserver). The address family of a Service defaults to the address family of the first service cluster IP
range (configured via the `--service-cluster-ip-range` flag to the kube-apiserver).
When you define a Service you can optionally configure it as dual stack. To specify the behavior you want, you When you define a Service you can optionally configure it as dual stack. To specify the behavior you want, you
set the `.spec.ipFamilyPolicy` field to one of the following values: set the `.spec.ipFamilyPolicy` field to one of the following values:
--> -->
你可以使用 IPv4 或 IPv6 地址来创建 你可以使用 IPv4 或 IPv6 地址来创建
{{< glossary_tooltip text="Service" term_id="service" >}}。 {{< glossary_tooltip text="Service" term_id="service" >}}。
服务的地址族默认为第一个服务集群 IP 范围的地址族(通过 kube-apiserver 的 服务的地址族默认为第一个服务集群 IP 范围的地址族(通过 kube-apiserver 的
`--service-cluster-ip-range` 参数配置)。 `--service-cluster-ip-range` 参数配置)。
当你定义服务时,可以选择将其配置为双栈。若要指定所需的行为,你可以设置 当你定义服务时,可以选择将其配置为双栈。若要指定所需的行为,你可以设置
`.spec.ipFamilyPolicy` 字段为以下值之一: `.spec.ipFamilyPolicy` 字段为以下值之一:
<!-- <!--
* `SingleStack`: Single-stack service. The control plane allocates a cluster IP for the Service, using the first configured service cluster IP range. * `SingleStack`: Single-stack service. The control plane allocates a cluster IP for the Service,
using the first configured service cluster IP range.
* `PreferDualStack`: * `PreferDualStack`:
* Allocates IPv4 and IPv6 cluster IPs for the Service. * Allocates IPv4 and IPv6 cluster IPs for the Service.
* `RequireDualStack`: Allocates Service `.spec.ClusterIPs` from both IPv4 and IPv6 address ranges. * `RequireDualStack`: Allocates Service `.spec.ClusterIPs` from both IPv4 and IPv6 address ranges.
* Selects the `.spec.ClusterIP` from the list of `.spec.ClusterIPs` based on the address family of the first element in the `.spec.ipFamilies` array. * Selects the `.spec.ClusterIP` from the list of `.spec.ClusterIPs` based on the address family
of the first element in the `.spec.ipFamilies` array.
--> -->
* `SingleStack`:单栈服务。控制面使用第一个配置的服务集群 IP 范围为服务分配集群 IP。 * `SingleStack`:单栈服务。控制面使用第一个配置的服务集群 IP 范围为服务分配集群 IP。
* `PreferDualStack` * `PreferDualStack`
* 为服务分配 IPv4 和 IPv6 集群 IP 地址。 * 为服务分配 IPv4 和 IPv6 集群 IP 地址。
@@ -175,14 +183,18 @@ set the `.spec.ipFamilyPolicy` field to one of the following values:
列表中选择 `.spec.ClusterIP` 列表中选择 `.spec.ClusterIP`
<!-- <!--
If you would like to define which IP family to use for single stack or define the order of IP families for dual-stack, you can choose the address families by setting an optional field, `.spec.ipFamilies`, on the Service. If you would like to define which IP family to use for single stack or define the order of IP
families for dual-stack, you can choose the address families by setting an optional field,
`.spec.ipFamilies`, on the Service.
--> -->
如果你想要定义哪个 IP 族用于单栈或定义双栈 IP 族的顺序,可以通过设置 如果你想要定义哪个 IP 族用于单栈或定义双栈 IP 族的顺序,可以通过设置
服务上的可选字段 `.spec.ipFamilies` 来选择地址族。 服务上的可选字段 `.spec.ipFamilies` 来选择地址族。
{{< note >}} {{< note >}}
<!-- <!--
The `.spec.ipFamilies` field is immutable because the `.spec.ClusterIP` cannot be reallocated on a Service that already exists. If you want to change `.spec.ipFamilies`, delete and recreate the Service. The `.spec.ipFamilies` field is immutable because the `.spec.ClusterIP` cannot be reallocated on a
Service that already exists. If you want to change `.spec.ipFamilies`, delete and recreate the
Service.
--> -->
`.spec.ipFamilies` 字段是不可变的,因为系统无法为已经存在的服务重新分配 `.spec.ipFamilies` 字段是不可变的,因为系统无法为已经存在的服务重新分配
`.spec.ClusterIP`。如果你想改变 `.spec.ipFamilies`,则需要删除并重新创建服务。 `.spec.ClusterIP`。如果你想改变 `.spec.ipFamilies`,则需要删除并重新创建服务。
@@ -214,34 +226,46 @@ The first family you list is used for the legacy `.spec.ClusterIP` field.
These examples demonstrate the behavior of various dual-stack Service configuration scenarios. These examples demonstrate the behavior of various dual-stack Service configuration scenarios.
--> -->
### 双栈服务配置场景 ### 双栈服务配置场景 {#dual-stack-service-configuration-scenarios}
以下示例演示多种双栈服务配置场景下的行为。 以下示例演示多种双栈服务配置场景下的行为。
<!-- <!--
#### Dual-stack options on new Services #### Dual-stack options on new Services
--> -->
#### 新服务的双栈选项 #### 新服务的双栈选项 {#dual-stack-options-on-new-services}
<!-- <!--
1. This Service specification does not explicitly define `.spec.ipFamilyPolicy`. When you create this Service, Kubernetes assigns a cluster IP for the Service from the first configured `service-cluster-ip-range` and sets the `.spec.ipFamilyPolicy` to `SingleStack`. ([Services without selectors](/docs/concepts/services-networking/service/#services-without-selectors) and [headless Services](/docs/concepts/services-networking/service/#headless-services) with selectors will behave in this same way.) 1. This Service specification does not explicitly define `.spec.ipFamilyPolicy`. When you create
this Service, Kubernetes assigns a cluster IP for the Service from the first configured
`service-cluster-ip-range` and sets the `.spec.ipFamilyPolicy` to `SingleStack`. ([Services
without selectors](/docs/concepts/services-networking/service/#services-without-selectors) and
[headless Services](/docs/concepts/services-networking/service/#headless-services) with selectors
will behave in this same way.)
--> -->
1. 此服务规约中没有显式设定 `.spec.ipFamilyPolicy`。当你创建此服务时,Kubernetes 1. 此服务规约中没有显式设定 `.spec.ipFamilyPolicy`。当你创建此服务时,Kubernetes
从所配置的第一个 `service-cluster-ip-range` 种为服务分配一个集群IP,并设置 从所配置的第一个 `service-cluster-ip-range` 种为服务分配一个集群IP,并设置
`.spec.ipFamilyPolicy``SingleStack` `.spec.ipFamilyPolicy``SingleStack`
[无选择算符的服务](/zh/docs/concepts/services-networking/service/#services-without-selectors) [无选择算符的服务](/zh-cn/docs/concepts/services-networking/service/#services-without-selectors)
和[无头服务](/zh/docs/concepts/services-networking/service/#headless-services)的行为方式 和[无头服务](/zh-cn/docs/concepts/services-networking/service/#headless-services)的行为方式
与此相同。) 与此相同。)
{{< codenew file="service/networking/dual-stack-default-svc.yaml" >}} {{< codenew file="service/networking/dual-stack-default-svc.yaml" >}}
<!-- <!--
1. This Service specification explicitly defines `PreferDualStack` in `.spec.ipFamilyPolicy`. When you create this Service on a dual-stack cluster, Kubernetes assigns both IPv4 and IPv6 addresses for the service. The control plane updates the `.spec` for the Service to record the IP address assignments. The field `.spec.ClusterIPs` is the primary field, and contains both assigned IP addresses; `.spec.ClusterIP` is a secondary field with its value calculated from `.spec.ClusterIPs`. 1. This Service specification explicitly defines `PreferDualStack` in `.spec.ipFamilyPolicy`. When
you create this Service on a dual-stack cluster, Kubernetes assigns both IPv4 and IPv6
* For the `.spec.ClusterIP` field, the control plane records the IP address that is from the same address family as the first service cluster IP range. addresses for the service. The control plane updates the `.spec` for the Service to record the IP
* On a single-stack cluster, the `.spec.ClusterIPs` and `.spec.ClusterIP` fields both only list one address. address assignments. The field `.spec.ClusterIPs` is the primary field, and contains both assigned
* On a cluster with dual-stack enabled, specifying `RequireDualStack` in `.spec.ipFamilyPolicy` behaves the same as `PreferDualStack`. IP addresses; `.spec.ClusterIP` is a secondary field with its value calculated from
`.spec.ClusterIPs`.
* For the `.spec.ClusterIP` field, the control plane records the IP address that is from the
same address family as the first service cluster IP range.
* On a single-stack cluster, the `.spec.ClusterIPs` and `.spec.ClusterIP` fields both only list
one address.
* On a cluster with dual-stack enabled, specifying `RequireDualStack` in `.spec.ipFamilyPolicy`
behaves the same as `PreferDualStack`.
--> -->
2. 此服务规约显式地将 `.spec.ipFamilyPolicy` 设置为 `PreferDualStack` 2. 此服务规约显式地将 `.spec.ipFamilyPolicy` 设置为 `PreferDualStack`
当你在双栈集群上创建此服务时,Kubernetes 会为该服务分配 IPv4 和 IPv6 地址。 当你在双栈集群上创建此服务时,Kubernetes 会为该服务分配 IPv4 和 IPv6 地址。
@@ -259,7 +283,10 @@ These examples demonstrate the behavior of various dual-stack Service configurat
{{< codenew file="service/networking/dual-stack-preferred-svc.yaml" >}} {{< codenew file="service/networking/dual-stack-preferred-svc.yaml" >}}
<!-- <!--
1. This Service specification explicitly defines `IPv6` and `IPv4` in `.spec.ipFamilies` as well as defining `PreferDualStack` in `.spec.ipFamilyPolicy`. When Kubernetes assigns an IPv6 and IPv4 address in `.spec.ClusterIPs`, `.spec.ClusterIP` is set to the IPv6 address because that is the first element in the `.spec.ClusterIPs` array, overriding the default. 1. This Service specification explicitly defines `IPv6` and `IPv4` in `.spec.ipFamilies` as well
as defining `PreferDualStack` in `.spec.ipFamilyPolicy`. When Kubernetes assigns an IPv6 and
IPv4 address in `.spec.ClusterIPs`, `.spec.ClusterIP` is set to the IPv6 address because that is
the first element in the `.spec.ClusterIPs` array, overriding the default.
--> -->
3. 下面的服务规约显式地在 `.spec.ipFamilies` 中指定 `IPv6``IPv4`,并 3. 下面的服务规约显式地在 `.spec.ipFamilies` 中指定 `IPv6``IPv4`,并
`.spec.ipFamilyPolicy` 设定为 `PreferDualStack` `.spec.ipFamilyPolicy` 设定为 `PreferDualStack`
@@ -272,16 +299,21 @@ These examples demonstrate the behavior of various dual-stack Service configurat
<!-- <!--
#### Dual-stack defaults on existing Services #### Dual-stack defaults on existing Services
--> -->
#### 现有服务的双栈默认值 #### 现有服务的双栈默认值 {#dual-stack-defaults-on-existing-services}
<!-- <!--
These examples demonstrate the default behavior when dual-stack is newly enabled on a cluster where Services already exist. (Upgrading an existing cluster to 1.21 or beyond will enable dual-stack.) These examples demonstrate the default behavior when dual-stack is newly enabled on a cluster
where Services already exist. (Upgrading an existing cluster to 1.21 or beyond will enable
dual-stack.)
--> -->
下面示例演示了在服务已经存在的集群上新启用双栈时的默认行为。 下面示例演示了在服务已经存在的集群上新启用双栈时的默认行为。
(将现有集群升级到 1.21 或者更高版本会启用双协议栈支持。) (将现有集群升级到 1.21 或者更高版本会启用双协议栈支持。)
<!-- <!--
1. When dual-stack is enabled on a cluster, existing Services (whether `IPv4` or `IPv6`) are configured by the control plane to set `.spec.ipFamilyPolicy` to `SingleStack` and set `.spec.ipFamilies` to the address family of the existing Service. The existing Service cluster IP will be stored in `.spec.ClusterIPs`. 1. When dual-stack is enabled on a cluster, existing Services (whether `IPv4` or `IPv6`) are
configured by the control plane to set `.spec.ipFamilyPolicy` to `SingleStack` and set
`.spec.ipFamilies` to the address family of the existing Service. The existing Service cluster IP
will be stored in `.spec.ClusterIPs`.
--> -->
1. 在集群上启用双栈时,控制面会将现有服务(无论是 `IPv4` 还是 `IPv6`)配置 1. 在集群上启用双栈时,控制面会将现有服务(无论是 `IPv4` 还是 `IPv6`)配置
`.spec.ipFamilyPolicy``SingleStack` 并设置 `.spec.ipFamilies` `.spec.ipFamilyPolicy``SingleStack` 并设置 `.spec.ipFamilies`
@@ -324,10 +356,15 @@ These examples demonstrate the default behavior when dual-stack is newly enabled
``` ```
<!-- <!--
1. When dual-stack is enabled on a cluster, existing [headless Services](/docs/concepts/services-networking/service/#headless-services) with selectors are configured by the control plane to set `.spec.ipFamilyPolicy` to `SingleStack` and set `.spec.ipFamilies` to the address family of the first service cluster IP range (configured via the `--service-cluster-ip-range` flag to the kube-apiserver) even though `.spec.ClusterIP` is set to `None`. 1. When dual-stack is enabled on a cluster, existing
[headless Services](/docs/concepts/services-networking/service/#headless-services) with selectors
are configured by the control plane to set `.spec.ipFamilyPolicy` to `SingleStack` and set
`.spec.ipFamilies` to the address family of the first service cluster IP range (configured via the
`--service-cluster-ip-range` flag to the kube-apiserver) even though `.spec.ClusterIP` is set to
`None`.
--> -->
2. 在集群上启用双栈时,带有选择算符的现有 2. 在集群上启用双栈时,带有选择算符的现有
[无头服务](/zh/docs/concepts/services-networking/service/#headless-services) [无头服务](/zh-cn/docs/concepts/services-networking/service/#headless-services)
由控制面设置 `.spec.ipFamilyPolicy` 为 `SingleStack` 由控制面设置 `.spec.ipFamilyPolicy` 为 `SingleStack`
并设置 `.spec.ipFamilies` 为第一个服务集群 IP 范围的地址族(通过配置 kube-apiserver 的 并设置 `.spec.ipFamilies` 为第一个服务集群 IP 范围的地址族(通过配置 kube-apiserver 的
`--service-cluster-ip-range` 参数),即使 `.spec.ClusterIP` 的设置值为 `None` 也如此。 `--service-cluster-ip-range` 参数),即使 `.spec.ClusterIP` 的设置值为 `None` 也如此。
@@ -368,7 +405,7 @@ These examples demonstrate the default behavior when dual-stack is newly enabled
<!-- <!--
#### Switching Services between single-stack and dual-stack #### Switching Services between single-stack and dual-stack
--> -->
#### 在单栈和双栈之间切换服务 #### 在单栈和双栈之间切换服务 {#switching-services-between-single-stack-and-dual-stack}
<!-- <!--
Services can be changed from single-stack to dual-stack and from dual-stack to single-stack. Services can be changed from single-stack to dual-stack and from dual-stack to single-stack.
@@ -376,14 +413,17 @@ Services can be changed from single-stack to dual-stack and from dual-stack to s
服务可以从单栈更改为双栈,也可以从双栈更改为单栈。 服务可以从单栈更改为双栈,也可以从双栈更改为单栈。
<!-- <!--
1. To change a Service from single-stack to dual-stack, change `.spec.ipFamilyPolicy` from `SingleStack` to `PreferDualStack` or `RequireDualStack` as desired. When you change this Service from single-stack to dual-stack, Kubernetes assigns the missing address family so that the Service now has IPv4 and IPv6 addresses. 1. To change a Service from single-stack to dual-stack, change `.spec.ipFamilyPolicy` from
`SingleStack` to `PreferDualStack` or `RequireDualStack` as desired. When you change this
Service from single-stack to dual-stack, Kubernetes assigns the missing address family so that the
Service now has IPv4 and IPv6 addresses.
Edit the Service specification updating the `.spec.ipFamilyPolicy` from `SingleStack` to `PreferDualStack`. Edit the Service specification updating the `.spec.ipFamilyPolicy` from `SingleStack` to `PreferDualStack`.
--> -->
1. 要将服务从单栈更改为双栈,根据需要将 `.spec.ipFamilyPolicy` 从 `SingleStack` 改为 1. 要将服务从单栈更改为双栈,根据需要将 `.spec.ipFamilyPolicy` 从 `SingleStack` 改为
`PreferDualStack` 或 `RequireDualStack`。 `PreferDualStack` 或 `RequireDualStack`。
当你将此服务从单栈更改为双栈时,Kubernetes 将分配缺失的地址族,以便现在 当你将此服务从单栈更改为双栈时,Kubernetes 将分配缺失的地址族,
该服务具有 IPv4 和 IPv6 地址。 以便现在该服务具有 IPv4 和 IPv6 地址。
编辑服务规约将 `.spec.ipFamilyPolicy` 从 `SingleStack` 改为 `PreferDualStack`。 编辑服务规约将 `.spec.ipFamilyPolicy` 从 `SingleStack` 改为 `PreferDualStack`。
<!-- <!--
@@ -407,9 +447,12 @@ Services can be changed from single-stack to dual-stack and from dual-stack to s
``` ```
<!-- <!--
1. To change a Service from dual-stack to single-stack, change `.spec.ipFamilyPolicy` from `PreferDualStack` or `RequireDualStack` to `SingleStack`. When you change this Service from dual-stack to single-stack, Kubernetes retains only the first element in the `.spec.ClusterIPs` array, and sets `.spec.ClusterIP` to that IP address and sets `.spec.ipFamilies` to the address family of `.spec.ClusterIPs`. 1. To change a Service from dual-stack to single-stack, change `.spec.ipFamilyPolicy` from
`PreferDualStack` or `RequireDualStack` to `SingleStack`. When you change this Service from
dual-stack to single-stack, Kubernetes retains only the first element in the `.spec.ClusterIPs`
array, and sets `.spec.ClusterIP` to that IP address and sets `.spec.ipFamilies` to the address
family of `.spec.ClusterIPs`.
--> -->
2. 要将服务从双栈更改为单栈,请将 `.spec.ipFamilyPolicy` 从 `PreferDualStack` 或 2. 要将服务从双栈更改为单栈,请将 `.spec.ipFamilyPolicy` 从 `PreferDualStack` 或
`RequireDualStack` 改为 `SingleStack`。 `RequireDualStack` 改为 `SingleStack`。
当你将此服务从双栈更改为单栈时,Kubernetes 只保留 `.spec.ClusterIPs` 当你将此服务从双栈更改为单栈时,Kubernetes 只保留 `.spec.ClusterIPs`
@@ -419,24 +462,27 @@ Services can be changed from single-stack to dual-stack and from dual-stack to s
<!-- <!--
### Headless Services without selector ### Headless Services without selector
--> -->
### 无选择算符的无头服务 ### 无选择算符的无头服务 {#headless-services-without-selector}
<!-- <!--
For [Headless Services without selectors](/docs/concepts/services-networking/service/#without-selectors) and without `.spec.ipFamilyPolicy` explicitly set, the `.spec.ipFamilyPolicy` field defaults to `RequireDualStack`. For [Headless Services without selectors](/docs/concepts/services-networking/service/#without-selectors)
and without `.spec.ipFamilyPolicy` explicitly set, the `.spec.ipFamilyPolicy` field defaults
to `RequireDualStack`.
--> -->
对于[不带选择算符的无头服务](/zh/docs/concepts/services-networking/service/#without-selectors) 对于[不带选择算符的无头服务](/zh-cn/docs/concepts/services-networking/service/#without-selectors)
若没有显式设置 `.spec.ipFamilyPolicy`,则 `.spec.ipFamilyPolicy` 若没有显式设置 `.spec.ipFamilyPolicy`,则 `.spec.ipFamilyPolicy`
字段默认设置为 `RequireDualStack`。 字段默认设置为 `RequireDualStack`。
<!-- <!--
### Service type LoadBalancer ### Service type LoadBalancer
--> -->
### LoadBalancer 类型服务 ### LoadBalancer 类型服务 {#service-type-loadbalancer}
<!-- <!--
To provision a dual-stack load balancer for your Service: To provision a dual-stack load balancer for your Service:
* Set the `.spec.type` field to `LoadBalancer`
* Set `.spec.ipFamilyPolicy` field to `PreferDualStack` or `RequireDualStack` * Set the `.spec.type` field to `LoadBalancer`
* Set `.spec.ipFamilyPolicy` field to `PreferDualStack` or `RequireDualStack`
--> -->
要为你的服务提供双栈负载均衡器: 要为你的服务提供双栈负载均衡器:
@@ -445,7 +491,8 @@ To provision a dual-stack load balancer for your Service:
{{< note >}} {{< note >}}
<!-- <!--
To use a dual-stack `LoadBalancer` type Service, your cloud provider must support IPv4 and IPv6 load balancers. To use a dual-stack `LoadBalancer` type Service, your cloud provider must support IPv4 and IPv6
load balancers.
--> -->
为了使用双栈的负载均衡器类型服务,你的云驱动必须支持 IPv4 和 IPv6 的负载均衡器。 为了使用双栈的负载均衡器类型服务,你的云驱动必须支持 IPv4 和 IPv6 的负载均衡器。
{{< /note >}} {{< /note >}}
@@ -453,10 +500,14 @@ To use a dual-stack `LoadBalancer` type Service, your cloud provider must suppor
<!-- <!--
## Egress traffic ## Egress traffic
--> -->
## 出站流量 ## 出站流量 {#egress-traffic}
<!-- <!--
If you want to enable egress traffic in order to reach off-cluster destinations (eg. the public Internet) from a Pod that uses non-publicly routable IPv6 addresses, you need to enable the Pod to use a publicly routed IPv6 address via a mechanism such as transparent proxying or IP masquerading. The [ip-masq-agent](https://github.com/kubernetes-sigs/ip-masq-agent) project supports IP masquerading on dual-stack clusters. If you want to enable egress traffic in order to reach off-cluster destinations (eg. the public
Internet) from a Pod that uses non-publicly routable IPv6 addresses, you need to enable the Pod to
use a publicly routed IPv6 address via a mechanism such as transparent proxying or IP
masquerading. The [ip-masq-agent](https://github.com/kubernetes-sigs/ip-masq-agent) project
supports IP masquerading on dual-stack clusters.
--> -->
如果你要启用出站流量,以便使用非公开路由 IPv6 地址的 Pod 到达集群外地址 如果你要启用出站流量,以便使用非公开路由 IPv6 地址的 Pod 到达集群外地址
(例如公网),则需要通过透明代理或 IP 伪装等机制使 Pod 使用公共路由的 (例如公网),则需要通过透明代理或 IP 伪装等机制使 Pod 使用公共路由的
@@ -479,15 +530,8 @@ dual-stack IPv4/IPv6 networking for pods and nodes with single-family services
is supported. is supported.
You can use IPv4/IPv6 dual-stack networking with `l2bridge` networks. You can use IPv4/IPv6 dual-stack networking with `l2bridge` networks.
{{< note >}}
Overlay (VXLAN) networks on Windows **do not** support dual-stack networking.
{{< /note >}}
You can read more about the different network modes for Windows within the
[Networking on Windows](/docs/concepts/services-networking/windows-networking#network-modes) topic.
--> -->
## Windows 支持 ## Windows 支持 {#windows-support}
Windows 上的 Kubernetes 不支持单栈“仅 IPv6” 网络。 然而, Windows 上的 Kubernetes 不支持单栈“仅 IPv6” 网络。 然而,
对于 Pod 和节点而言,仅支持单栈形式服务的双栈 IPv4/IPv6 网络是被支持的。 对于 Pod 和节点而言,仅支持单栈形式服务的双栈 IPv4/IPv6 网络是被支持的。
@@ -495,11 +539,18 @@ Windows 上的 Kubernetes 不支持单栈“仅 IPv6” 网络。 然而,
你可以使用 `l2bridge` 网络来实现 IPv4/IPv6 双栈联网。 你可以使用 `l2bridge` 网络来实现 IPv4/IPv6 双栈联网。
{{< note >}} {{< note >}}
<!--
Overlay (VXLAN) networks on Windows **do not** support dual-stack networking.
-->
Windows 上的 Overlay (VXLAN) 网络**不**支持双栈网络。 Windows 上的 Overlay (VXLAN) 网络**不**支持双栈网络。
{{< /note >}} {{< /note >}}
<!--
You can read more about the different network modes for Windows within the
[Networking on Windows](/docs/concepts/services-networking/windows-networking#network-modes) topic.
-->
关于 Windows 的不同网络模式,你可以进一步阅读 关于 Windows 的不同网络模式,你可以进一步阅读
[Windows 上的网络](/zh/docs/concepts/services-networking/windows-networking#network-modes)。 [Windows 上的网络](/zh-cn/docs/concepts/services-networking/windows-networking#network-modes)。
## {{% heading "whatsnext" %}} ## {{% heading "whatsnext" %}}
@@ -507,5 +558,5 @@ Windows 上的 Overlay (VXLAN) 网络**不**支持双栈网络。
* [Validate IPv4/IPv6 dual-stack](/docs/tasks/network/validate-dual-stack) networking * [Validate IPv4/IPv6 dual-stack](/docs/tasks/network/validate-dual-stack) networking
* [Enable dual-stack networking using kubeadm](/docs/setup/production-environment/tools/kubeadm/dual-stack-support/) * [Enable dual-stack networking using kubeadm](/docs/setup/production-environment/tools/kubeadm/dual-stack-support/)
--> -->
* [验证 IPv4/IPv6 双协议栈](/zh/docs/tasks/network/validate-dual-stack)网络 * [验证 IPv4/IPv6 双协议栈](/zh-cn/docs/tasks/network/validate-dual-stack)网络
* [使用 kubeadm 启用双协议栈网络](/zh/docs/setup/production-environment/tools/kubeadm/dual-stack-support/) * [使用 kubeadm 启用双协议栈网络](/zh-cn/docs/setup/production-environment/tools/kubeadm/dual-stack-support/)