Skip to content

Commit 9070bf1

Browse files
committed
[zh-cn] Sync services-networking/*
Signed-off-by: xin.li <[email protected]>
1 parent 9c3d134 commit 9070bf1

File tree

3 files changed

+50
-51
lines changed

3 files changed

+50
-51
lines changed

content/zh-cn/docs/concepts/services-networking/_index.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ description: Kubernetes 网络背后的概念和资源。
77
<!--
88
## The Kubernetes network model
99
10-
Every [`Pod`](/docs/concepts/workloads/pods/) in a cluster gets its own unique cluster-wide IP address.
10+
Every [`Pod`](/docs/concepts/workloads/pods/) in a cluster gets its own unique cluster-wide IP address
11+
(one address per IP address family).
1112
This means you do not need to explicitly create links between `Pods` and you
1213
almost never need to deal with mapping container ports to host ports.
1314
This creates a clean, backwards-compatible model where `Pods` can be treated
@@ -18,7 +19,7 @@ application configuration, and migration.
1819
## Kubernetes 网络模型 {#the-kubernetes-network-model}
1920

2021
集群中每一个 [`Pod`](/zh-cn/docs/concepts/workloads/pods/) 都会获得自己的、
21-
独一无二的 IP 地址,
22+
独一无二的 IP 地址(每个 IP 地址族一个地址)
2223
这就意味着你不需要显式地在 `Pod` 之间创建链接,你几乎不需要处理容器端口到主机端口之间的映射。
2324
这将形成一个干净的、向后兼容的模型;在这个模型里,从端口分配、命名、服务发现、
2425
[负载均衡](/zh-cn/docs/concepts/services-networking/ingress/#load-balancing)
@@ -41,11 +42,9 @@ Kubernetes 强制要求所有网络设施都满足以下基本要求(从而排
4142
* 节点上的代理(比如:系统守护进程、kubelet)可以和节点上的所有 Pod 通信
4243

4344
<!--
44-
Note: For those platforms that support `Pods` running in the host network (e.g.
45-
Linux), when pods are attached to the host network of a node they can still communicate
46-
with all pods on all nodes without NAT.
45+
For those platforms that support `Pods` running in the host network (such as Linux), when pods are attached to the host network of a node they can still communicate with all pods on all nodes without NAT.
4746
-->
48-
说明:对于支持在主机网络中运行 `Pod` 的平台(比如:Linux),
47+
对于支持在主机网络中运行 `Pod` 的平台(比如:Linux),
4948
当 Pod 挂接到节点的宿主网络上时,它们仍可以不通过 NAT 和所有节点上的 Pod 通信。
5049

5150
<!--

content/zh-cn/docs/concepts/services-networking/dual-stack.md

+28-28
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,16 @@ Service 的地址族默认为第一个服务集群 IP 范围的地址族(通
179179
using the first configured service cluster IP range.
180180
* `PreferDualStack`:Allocates both IPv4 and IPv6 cluster IPs for the Service when dual-stack is enabled. If dual-stack is not enabled or supported, it falls back to single-stack behavior.
181181
* `RequireDualStack`: Allocates Service `.spec.clusterIPs` from both IPv4 and IPv6 address ranges when dual-stack is enabled. If dual-stack is not enabled or supported, the Service API object creation fails.
182-
* Selects the `.spec.ClusterIP` from the list of `.spec.ClusterIPs` based on the address family
182+
* Selects the `.spec.clusterIP` from the list of `.spec.clusterIPs` based on the address family
183183
of the first element in the `.spec.ipFamilies` array.
184184
-->
185185
* `SingleStack`:单栈 Service。控制面使用第一个配置的服务集群 IP 范围为 Service 分配集群 IP。
186186
* `PreferDualStack`:启用双栈时,为 Service 同时分配 IPv4 和 IPv6 集群 IP 地址。
187187
如果双栈未被启用或不被支持,则会返回到单栈行为。
188-
* `RequireDualStack`:启用双栈时,同时从 IPv4 和 IPv6 的地址范围中分配 Service 的 `.spec.ClusterIPs`
188+
* `RequireDualStack`:启用双栈时,同时从 IPv4 和 IPv6 的地址范围中分配 Service 的 `.spec.clusterIPs`
189189
如果双栈未被启用或不被支持,则 Service API 对象创建失败。
190-
* 从基于在 `.spec.ipFamilies` 数组中第一个元素的地址族的 `.spec.ClusterIPs`
191-
列表中选择 `.spec.ClusterIP`
190+
* 从基于在 `.spec.ipFamilies` 数组中第一个元素的地址族的 `.spec.clusterIPs`
191+
列表中选择 `.spec.clusterIP`
192192

193193
<!--
194194
If you would like to define which IP family to use for single stack or define the order of IP
@@ -224,9 +224,9 @@ You can set `.spec.ipFamilies` to any of the following array values:
224224
- `["IPv6","IPv4"]` (双栈)
225225

226226
<!--
227-
The first family you list is used for the legacy `.spec.ClusterIP` field.
227+
The first family you list is used for the legacy `.spec.clusterIP` field.
228228
-->
229-
你所列出的第一个地址族用于原来的 `.spec.ClusterIP` 字段。
229+
你所列出的第一个地址族用于原来的 `.spec.clusterIP` 字段。
230230

231231
<!--
232232
### Dual-stack Service configuration scenarios
@@ -262,26 +262,26 @@ These examples demonstrate the behavior of various dual-stack Service configurat
262262
1. This Service specification explicitly defines `PreferDualStack` in `.spec.ipFamilyPolicy`. When
263263
you create this Service on a dual-stack cluster, Kubernetes assigns both IPv4 and IPv6
264264
addresses for the service. The control plane updates the `.spec` for the Service to record the IP
265-
address assignments. The field `.spec.ClusterIPs` is the primary field, and contains both assigned
266-
IP addresses; `.spec.ClusterIP` is a secondary field with its value calculated from
267-
`.spec.ClusterIPs`.
265+
address assignments. The field `.spec.clusterIPs` is the primary field, and contains both assigned
266+
IP addresses; `.spec.clusterIP` is a secondary field with its value calculated from
267+
`.spec.clusterIPs`.
268268
269-
* For the `.spec.ClusterIP` field, the control plane records the IP address that is from the
269+
* For the `.spec.clusterIP` field, the control plane records the IP address that is from the
270270
same address family as the first service cluster IP range.
271-
* On a single-stack cluster, the `.spec.ClusterIPs` and `.spec.ClusterIP` fields both only list
271+
* On a single-stack cluster, the `.spec.clusterIPs` and `.spec.clusterIP` fields both only list
272272
one address.
273273
* On a cluster with dual-stack enabled, specifying `RequireDualStack` in `.spec.ipFamilyPolicy`
274274
behaves the same as `PreferDualStack`.
275275
-->
276276
2. 此 Service 规约显式地将 `.spec.ipFamilyPolicy` 设置为 `PreferDualStack`
277277
当你在双栈集群上创建此 Service 时,Kubernetes 会为此 Service 分配 IPv4 和 IPv6 地址。
278278
控制平面更新 Service 的 `.spec` 以记录 IP 地址分配。
279-
字段 `.spec.ClusterIPs` 是主要字段,包含两个分配的 IP 地址;`.spec.ClusterIP` 是次要字段,
280-
其取值从 `.spec.ClusterIPs` 计算而来。
279+
字段 `.spec.clusterIPs` 是主要字段,包含两个分配的 IP 地址;`.spec.clusterIP` 是次要字段,
280+
其取值从 `.spec.clusterIPs` 计算而来。
281281

282-
* 对于 `.spec.ClusterIP` 字段,控制面记录来自第一个服务集群 IP
282+
* 对于 `.spec.clusterIP` 字段,控制面记录来自第一个服务集群 IP
283283
范围对应的地址族的 IP 地址。
284-
* 对于单协议栈的集群,`.spec.ClusterIPs``.spec.ClusterIP` 字段都
284+
* 对于单协议栈的集群,`.spec.clusterIPs``.spec.clusterIP` 字段都
285285
仅仅列出一个地址。
286286
* 对于启用了双协议栈的集群,将 `.spec.ipFamilyPolicy` 设置为
287287
`RequireDualStack` 时,其行为与 `PreferDualStack` 相同。
@@ -291,13 +291,13 @@ These examples demonstrate the behavior of various dual-stack Service configurat
291291
<!--
292292
1. This Service specification explicitly defines `IPv6` and `IPv4` in `.spec.ipFamilies` as well
293293
as defining `PreferDualStack` in `.spec.ipFamilyPolicy`. When Kubernetes assigns an IPv6 and
294-
IPv4 address in `.spec.ClusterIPs`, `.spec.ClusterIP` is set to the IPv6 address because that is
295-
the first element in the `.spec.ClusterIPs` array, overriding the default.
294+
IPv4 address in `.spec.clusterIPs`, `.spec.clusterIP` is set to the IPv6 address because that is
295+
the first element in the `.spec.clusterIPs` array, overriding the default.
296296
-->
297297
3. 下面的 Service 规约显式地在 `.spec.ipFamilies` 中指定 `IPv6``IPv4`,并将
298298
`.spec.ipFamilyPolicy` 设定为 `PreferDualStack`
299-
当 Kubernetes 为 `.spec.ClusterIPs` 分配一个 IPv6 和一个 IPv4 地址时,
300-
`.spec.ClusterIP` 被设置成 IPv6 地址,因为它是 `.spec.ClusterIPs` 数组中的第一个元素,
299+
当 Kubernetes 为 `.spec.clusterIPs` 分配一个 IPv6 和一个 IPv4 地址时,
300+
`.spec.clusterIP` 被设置成 IPv6 地址,因为它是 `.spec.clusterIPs` 数组中的第一个元素,
301301
覆盖其默认值。
302302

303303
{{% code_sample file="service/networking/dual-stack-preferred-ipfamilies-svc.yaml" %}}
@@ -319,7 +319,7 @@ dual-stack.)
319319
1. When dual-stack is enabled on a cluster, existing Services (whether `IPv4` or `IPv6`) are
320320
configured by the control plane to set `.spec.ipFamilyPolicy` to `SingleStack` and set
321321
`.spec.ipFamilies` to the address family of the existing Service. The existing Service cluster IP
322-
will be stored in `.spec.ClusterIPs`.
322+
will be stored in `.spec.clusterIPs`.
323323
-->
324324
1. 在集群上启用双栈时,控制面会将现有 Service(无论是 `IPv4` 还是 `IPv6`)配置
325325
`.spec.ipFamilyPolicy``SingleStack` 并设置 `.spec.ipFamilies`
@@ -366,14 +366,14 @@ dual-stack.)
366366
[headless Services](/docs/concepts/services-networking/service/#headless-services) with selectors are
367367
configured by the control plane to set `.spec.ipFamilyPolicy` to `SingleStack` and set
368368
`.spec.ipFamilies` to the address family of the first service cluster IP range (configured via the
369-
`--service-cluster-ip-range` flag to the kube-apiserver) even though `.spec.ClusterIP` is set to
369+
`--service-cluster-ip-range` flag to the kube-apiserver) even though `.spec.clusterIP` is set to
370370
`None`.
371371
-->
372372
2. 在集群上启用双栈时,带有选择算符的现有
373373
[无头服务](/zh-cn/docs/concepts/services-networking/service/#headless-services)
374374
由控制面设置 `.spec.ipFamilyPolicy` 为 `SingleStack`
375375
并设置 `.spec.ipFamilies` 为第一个服务集群 IP 范围的地址族(通过配置 kube-apiserver 的
376-
`--service-cluster-ip-range` 参数),即使 `.spec.ClusterIP` 的设置值为 `None` 也如此。
376+
`--service-cluster-ip-range` 参数),即使 `.spec.clusterIP` 的设置值为 `None` 也如此。
377377

378378
{{% code_sample file="service/networking/dual-stack-default-svc.yaml" %}}
379379

@@ -455,15 +455,15 @@ Service 可以从单栈更改为双栈,也可以从双栈更改为单栈。
455455
<!--
456456
1. To change a Service from dual-stack to single-stack, change `.spec.ipFamilyPolicy` from
457457
`PreferDualStack` or `RequireDualStack` to `SingleStack`. When you change this Service from
458-
dual-stack to single-stack, Kubernetes retains only the first element in the `.spec.ClusterIPs`
459-
array, and sets `.spec.ClusterIP` to that IP address and sets `.spec.ipFamilies` to the address
460-
family of `.spec.ClusterIPs`.
458+
dual-stack to single-stack, Kubernetes retains only the first element in the `.spec.clusterIPs`
459+
array, and sets `.spec.clusterIP` to that IP address and sets `.spec.ipFamilies` to the address
460+
family of `.spec.clusterIPs`.
461461
-->
462462
2. 要将 Service 从双栈更改为单栈,请将 `.spec.ipFamilyPolicy` 从 `PreferDualStack` 或
463463
`RequireDualStack` 改为 `SingleStack`。
464-
当你将此 Service 从双栈更改为单栈时,Kubernetes 只保留 `.spec.ClusterIPs`
465-
数组中的第一个元素,并设置 `.spec.ClusterIP` 为那个 IP 地址,
466-
并设置 `.spec.ipFamilies` 为 `.spec.ClusterIPs` 地址族。
464+
当你将此 Service 从双栈更改为单栈时,Kubernetes 只保留 `.spec.clusterIPs`
465+
数组中的第一个元素,并设置 `.spec.clusterIP` 为那个 IP 地址,
466+
并设置 `.spec.ipFamilies` 为 `.spec.clusterIPs` 地址族。
467467

468468
<!--
469469
### Headless Services without selector

content/zh-cn/docs/concepts/services-networking/service.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ read [Virtual IPs and Service Proxies](/docs/reference/networking/virtual-ips/).
224224
[服务类型](#publishing-services-service-types)默认为 ClusterIP 的 Service。
225225
该 Service 指向带有标签 `app.kubernetes.io/name: MyApp` 的所有 Pod 的 TCP 端口 9376。
226226

227-
Kubernetes 为该服务分配一个 IP 地址(称为 “集群 IP”),供虚拟 IP 地址机制使用。
227+
Kubernetes 为该 Service 分配一个 IP 地址(称为 “集群 IP”),供虚拟 IP 地址机制使用。
228228
有关该机制的更多详情,请阅读[虚拟 IP 和服务代理](/zh-cn/docs/reference/networking/virtual-ips/)。
229229

230230
<!--
@@ -317,7 +317,7 @@ Each port definition can have the same `protocol`, or a different one.
317317
Service 的默认协议是 [TCP](/zh-cn/docs/reference/networking/service-protocols/#protocol-tcp);
318318
你还可以使用其他[受支持的任何协议](/zh-cn/docs/reference/networking/service-protocols/)。
319319

320-
由于许多 Service 需要公开多个端口,所以 Kubernetes 为同一服务定义[多个端口](#multi-port-services)。
320+
由于许多 Service 需要公开多个端口,所以 Kubernetes 为同一 Service 定义[多个端口](#multi-port-services)。
321321
每个端口定义可以具有相同的 `protocol`,也可以具有不同协议。
322322

323323
<!--
@@ -408,14 +408,14 @@ endpoints:
408408
apiVersion: discovery.k8s.io/v1
409409
kind: EndpointSlice
410410
metadata:
411-
name: my-service-1 # 按惯例将服务的名称用作 EndpointSlice 名称的前缀
411+
name: my-service-1 # 按惯例将 Service 的名称用作 EndpointSlice 名称的前缀
412412
labels:
413413
# 你应设置 "kubernetes.io/service-name" 标签。
414-
# 设置其值以匹配服务的名称
414+
# 设置其值以匹配 Service 的名称
415415
kubernetes.io/service-name: my-service
416416
addressType: IPv4
417417
ports:
418-
- name: '' # 应与上面定义的服务端口的名称匹配
418+
- name: '' # 应与上面定义的 Service 端口的名称匹配
419419
appProtocol: http
420420
protocol: TCP
421421
port: 9376
@@ -539,7 +539,7 @@ See [EndpointSlices](/docs/concepts/services-networking/endpoint-slices/) for mo
539539
information about this API.
540540
-->
541541
[EndpointSlice](/zh-cn/docs/concepts/services-networking/endpoint-slices/)
542-
对象表示某个服务的后端网络端点的子集(**切片**)。
542+
对象表示某个 Service 的后端网络端点的子集(**切片**)。
543543

544544
你的 Kubernetes 集群会跟踪每个 EndpointSlice 所表示的端点数量。
545545
如果 Service 的端点太多以至于达到阈值,Kubernetes 会添加另一个空的
@@ -737,14 +737,14 @@ Kubernetes Service 类型允许指定你所需要的 Service 类型。
737737
-->
738738
`ClusterIP`
739739
: 通过集群的内部 IP 公开 Service,选择该值时 Service 只能够在集群内部访问。
740-
这也是你没有为服务显式指定 `type` 时使用的默认值。
740+
这也是你没有为 Service 显式指定 `type` 时使用的默认值。
741741
你可以使用 [Ingress](/zh-cn/docs/concepts/services-networking/ingress/)
742742
或者 [Gateway API](https://gateway-api.sigs.k8s.io/) 向公共互联网公开服务。
743743

744744
[`NodePort`](#type-nodeport)
745745
: 通过每个节点上的 IP 和静态端口(`NodePort`)公开 Service。
746746
为了让 Service 可通过节点端口访问,Kubernetes 会为 Service 配置集群 IP 地址,
747-
相当于你请求了 `type: ClusterIP` 的服务
747+
相当于你请求了 `type: ClusterIP` 的 Service
748748

749749
<!--
750750
[`LoadBalancer`](#loadbalancer)
@@ -775,7 +775,7 @@ define a `LoadBalancer` Service by
775775
-->
776776
服务 API 中的 `type` 字段被设计为层层递进的形式 - 每层都建立在前一层的基础上。
777777
但是,这种层层递进的形式有一个例外。
778-
你可以在定义 `LoadBalancer` 服务时[禁止负载均衡器分配 `NodePort`](/zh-cn/docs/concepts/services-networking/service/#load-balancer-nodeport-allocation)。
778+
你可以在定义 `LoadBalancer` Service 时[禁止负载均衡器分配 `NodePort`](/zh-cn/docs/concepts/services-networking/service/#load-balancer-nodeport-allocation)。
779779

780780
<!--
781781
### `type: ClusterIP` {#type-clusterip}
@@ -861,7 +861,7 @@ endpoints associated with that Service. You'll be able to contact the `type: Nod
861861
Service, from outside the cluster, by connecting to any node using the appropriate
862862
protocol (for example: TCP), and the appropriate port (as assigned to that Service).
863863
-->
864-
对于 NodePort 服务,Kubernetes 额外分配一个端口(TCP、UDP 或 SCTP 以匹配 Service 的协议)。
864+
对于 NodePort 类型 Service,Kubernetes 额外分配一个端口(TCP、UDP 或 SCTP 以匹配 Service 的协议)。
865865
集群中的每个节点都将自己配置为监听所分配的端口,并将流量转发到与该 Service 关联的某个就绪端点。
866866
通过使用合适的协议(例如 TCP)和适当的端口(分配给该 Service)连接到任何一个节点,
867867
你就能够从集群外部访问 `type: NodePort` 服务。
@@ -1300,17 +1300,17 @@ Select one of the tabs.
13001300
metadata:
13011301
name: my-service
13021302
annotations:
1303-
networking.gke.io/load-balancer-type: "Internal"
1303+
networking.gke.io/load-balancer-type: "Internal"
13041304
```
13051305

13061306
{{% /tab %}}
13071307
{{% tab name="AWS" %}}
13081308

13091309
```yaml
13101310
metadata:
1311-
name: my-service
1312-
annotations:
1313-
service.beta.kubernetes.io/aws-load-balancer-internal: "true"
1311+
name: my-service
1312+
annotations:
1313+
service.beta.kubernetes.io/aws-load-balancer-internal: "true"
13141314
```
13151315

13161316
{{% /tab %}}
@@ -1320,7 +1320,7 @@ metadata:
13201320
metadata:
13211321
name: my-service
13221322
annotations:
1323-
service.beta.kubernetes.io/azure-load-balancer-internal: "true"
1323+
service.beta.kubernetes.io/azure-load-balancer-internal: "true"
13241324
```
13251325

13261326
{{% /tab %}}
@@ -1330,7 +1330,7 @@ metadata:
13301330
metadata:
13311331
name: my-service
13321332
annotations:
1333-
service.kubernetes.io/ibm-load-balancer-cloud-provider-ip-type: "private"
1333+
service.kubernetes.io/ibm-load-balancer-cloud-provider-ip-type: "private"
13341334
```
13351335

13361336
{{% /tab %}}
@@ -1809,7 +1809,7 @@ Kubernetes 所配置的规则和路由会确保流量被路由到该 Service 的
18091809

18101810
定义 Service 时,你可以为任何[服务类型](#publishing-services-service-types)指定 `externalIPs`。
18111811

1812-
在下面的例子中,名为 `my-service` 的服务可以在 "`198.51.100.32:80`"
1812+
在下面的例子中,名为 `my-service` 的 Service 可以在 "`198.51.100.32:80`"
18131813
(根据 `.spec.externalIPs[]` 和 `.spec.ports[].port` 得出)上被客户端使用 TCP 协议访问。
18141814

18151815
```yaml

0 commit comments

Comments
 (0)