Skip to content

Commit 37b120d

Browse files
committed
[zh] Resync concepts section (5)
1 parent 2ce78eb commit 37b120d

File tree

2 files changed

+161
-87
lines changed

2 files changed

+161
-87
lines changed

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

Lines changed: 74 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
---
2-
title: 服务拓扑(Service Topology)
3-
feature:
4-
title: 服务拓扑(Service Topology)
5-
description: >
6-
基于集群拓扑的服务流量路由。
7-
2+
title: 使用拓扑键实现拓扑感知的流量路由
83
content_type: concept
94
weight: 10
105
---
116
<!--
127
reviewers:
138
- johnbelamaric
149
- imroc
15-
title: Service Topology
16-
feature:
17-
title: Service Topology
18-
description: >
19-
Routing of service traffic based upon cluster topology.
20-
10+
title: Topology-aware traffic routing with topology keys
2111
content_type: concept
2212
weight: 10
2313
-->
2414

2515
<!-- overview -->
2616

27-
{{< feature-state for_k8s_version="v1.17" state="alpha" >}}
17+
{{< feature-state for_k8s_version="v1.21" state="deprecated" >}}
18+
19+
{{< note >}}
20+
<!--
21+
This feature, specifically the alpha `topologyKeys` API, is deprecated since
22+
Kubernetes v1.21.
23+
[Topology Aware Hints](/docs/concepts/services-networking/topology-aware-hints/),
24+
introduced in Kubernetes v1.21, provide similar functionality.
25+
-->
26+
此功能特性,尤其是 Alpha 阶段的 `topologyKeys` API,在 Kubernetes v1.21
27+
版本中已被废弃。Kubernetes v1.21 版本中引入的
28+
[拓扑感知的提示](/zh/docs/concepts/services-networking/topology-aware-hints/),
29+
提供类似的功能。
30+
{{</ note >}}
2831

2932
<!--
3033
_Service Topology_ enables a service to route traffic based upon the Node
@@ -38,53 +41,58 @@ in the same availability zone.
3841
<!-- body -->
3942

4043
<!--
41-
## Introduction
44+
## Topology-aware traffic routing
4245
4346
By default, traffic sent to a `ClusterIP` or `NodePort` Service may be routed to
44-
any backend address for the Service. Since Kubernetes 1.7 it has been possible
45-
to route "external" traffic to the Pods running on the Node that received the
46-
traffic, but this is not supported for `ClusterIP` Services, and more complex
47-
topologies &mdash; such as routing zonally &mdash; have not been possible. The
48-
_Service Topology_ feature resolves this by allowing the Service creator to
49-
define a policy for routing traffic based upon the Node labels for the
50-
originating and destination Nodes.
51-
52-
By using Node label matching between the source and destination, the operator
53-
may designate groups of Nodes that are "closer" and "farther" from one another,
54-
using whatever metric makes sense for that operator's requirements. For many
55-
operators in public clouds, for example, there is a preference to keep service
56-
traffic within the same zone, because interzonal traffic has a cost associated
57-
with it, while intrazonal traffic does not. Other common needs include being able
58-
to route traffic to a local Pod managed by a DaemonSet, or keeping traffic to
59-
Nodes connected to the same top-of-rack switch for the lowest latency.
47+
any backend address for the Service. Kubernetes 1.7 made it possible to
48+
route "external" traffic to the Pods running on the same Node that received the
49+
traffic. For `ClusterIP` Services, the equivalent same-node preference for
50+
routing wasn't possible; nor could you configure your cluster to favor routing
51+
to endpoints within the same zone.
52+
By setting `topologyKeys` on a Service, you're able to define a policy for routing
53+
traffic based upon the Node labels for the originating and destination Nodes.
6054
-->
61-
## 介绍 {#introduction}
55+
## 拓扑感知的流量路由
6256

63-
默认情况下,发往 `ClusterIP` 或者 `NodePort` 服务的流量可能会被路由到任意一个服务后端的地址上。
64-
从 Kubernetes 1.7 开始,可以将“外部”流量路由到节点上运行的 Pod 上,但不支持 `ClusterIP` 服务,
65-
更复杂的拓扑 &mdash; 比如分区路由 &mdash; 也还不支持。
66-
通过允许 `Service` 创建者根据源 `Node` 和目的 `Node` 的标签来定义流量路由策略,
67-
服务拓扑特性实现了服务流量的路由。
57+
默认情况下,发往 `ClusterIP` 或者 `NodePort` 服务的流量可能会被路由到
58+
服务的任一后端的地址。Kubernetes 1.7 允许将“外部”流量路由到接收到流量的
59+
节点上的 Pod。对于 `ClusterIP` 服务,无法完成同节点优先的路由,你也无法
60+
配置集群优选路由到同一可用区中的端点。
61+
通过在 Service 上配置 `topologyKeys`,你可以基于来源节点和目标节点的
62+
标签来定义流量路由策略。
6863

69-
通过对源 `Node` 和目的 `Node` 标签的匹配,运营者可以使用任何符合运营者要求的度量值
70-
来指定彼此“较近”和“较远”的节点组。
71-
例如,对于在公有云上的运营者来说,更偏向于把流量控制在同一区域内,
72-
因为区域间的流量是有费用成本的,而区域内的流量没有。
73-
其它常用需求还包括把流量路由到由 `DaemonSet` 管理的本地 Pod 上,或者
74-
把保持流量在连接同一机架交换机的 `Node` 上,以获得低延时。
64+
<!--
65+
The label matching between the source and destination lets you, as a cluster
66+
operator, designate sets of Nodes that are "closer" and "farther" from one another.
67+
You can define labels to represent whatever metric makes sense for your own
68+
requirements.
69+
In public clouds, for example, you might prefer to keep network traffic within the
70+
same zone, because interzonal traffic has a cost associated with it (and intrazonal
71+
traffic typically does not). Other common needs include being able to route traffic
72+
to a local Pod managed by a DaemonSet, or directing traffic to Nodes connected to the
73+
same top-of-rack switch for the lowest latency.
74+
-->
75+
通过对源和目的之间的标签匹配,作为集群操作者的你可以根据节点间彼此“较近”和“较远”
76+
来定义节点集合。你可以基于符合自身需求的任何度量值来定义标签。
77+
例如,在公有云上,你可能更偏向于把流量控制在同一区内,因为区间流量是有费用成本的,
78+
而区内流量则没有。
79+
其它常见需求还包括把流量路由到由 `DaemonSet` 管理的本地 Pod 上,或者
80+
把将流量转发到连接在同一机架交换机的节点上,以获得低延时。
7581

7682
<!--
7783
## Using Service Topology
7884
79-
If your cluster has Service Topology enabled, you can control Service traffic
85+
If your cluster has the `ServiceTopology`
86+
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
87+
enabled, you can control Service traffic
8088
routing by specifying the `topologyKeys` field on the Service spec. This field
8189
is a preference-order list of Node labels which will be used to sort endpoints
8290
when accessing this Service. Traffic will be directed to a Node whose value for
8391
the first label matches the originating Node's value for that label. If there is
8492
no backend for the Service on a matching Node, then the second label will be
8593
considered, and so forth, until no labels remain.
8694
87-
If no match is found, the traffic will be rejected, just as if there were no
95+
If no match is found, the traffic will be rejected, as if there were no
8896
backends for the Service at all. That is, endpoints are chosen based on the first
8997
topology key with available backends. If this field is specified and all entries
9098
have no backends that match the topology of the client, the service has no
@@ -95,8 +103,9 @@ as the last value in the list.
95103

96104
## 使用服务拓扑 {#using-service-topology}
97105

98-
如果集群启用了服务拓扑功能后,就可以在 `Service` 配置中指定 `topologyKeys` 字段,
99-
从而控制 `Service` 的流量路由。
106+
如果集群启用了 `ServiceTopology`
107+
[特性门控](/zh/docs/reference/command-line-tools-reference/feature-gates/)
108+
你就可以在 Service 规约中设定 `topologyKeys` 字段,从而控制其流量路由。
100109
此字段是 `Node` 标签的优先顺序字段,将用于在访问这个 `Service` 时对端点进行排序。
101110
流量会被定向到第一个标签值和源 `Node` 标签值相匹配的 `Node`
102111
如果这个 `Service` 没有匹配的后端 `Node`,那么第二个标签会被使用做匹配,
@@ -144,7 +153,7 @@ traffic as follows.
144153
145154
* Service topology is not compatible with `externalTrafficPolicy=Local`, and
146155
therefore a Service cannot use both of these features. It is possible to use
147-
both features in the same cluster on different Services, just not on the same
156+
both features in the same cluster on different Services, only not on the same
148157
Service.
149158
150159
* Valid topology keys are currently limited to `kubernetes.io/hostname`,
@@ -156,11 +165,11 @@ traffic as follows.
156165
* The catch-all value, `"*"`, must be the last value in the topology keys, if
157166
it is used.
158167
-->
159-
160168
## 约束条件 {#constraints}
161169

162170
* 服务拓扑和 `externalTrafficPolicy=Local` 是不兼容的,所以 `Service` 不能同时使用这两种特性。
163-
但是在同一个集群的不同 `Service` 上是可以分别使用这两种特性的,只要不在同一个 `Service` 上就可以。
171+
但是在同一个集群的不同 `Service` 上是可以分别使用这两种特性的,只要不在同一个
172+
`Service` 上就可以。
164173

165174
* 有效的拓扑键目前只有:`kubernetes.io/hostname``topology.kubernetes.io/zone`
166175
`topology.kubernetes.io/region`,但是未来会推广到其它的 `Node` 标签。
@@ -171,23 +180,21 @@ traffic as follows.
171180

172181
<!--
173182
## Examples
174-
-->
175-
## 示例
176183
177-
<!--
178184
The following are common examples of using the Service Topology feature.
179185
-->
186+
## 示例
187+
180188
以下是使用服务拓扑功能的常见示例。
181189

182190
<!--
183191
### Only Node Local Endpoints
184-
-->
185-
### 仅节点本地端点
186192
187-
<!--
188193
A Service that only routes to node local endpoints. If no endpoints exist on the node, traffic is dropped:
189194
-->
190-
仅路由到节点本地端点的一种服务。 如果节点上不存在端点,流量则被丢弃:
195+
### 仅节点本地端点
196+
197+
仅路由到节点本地端点的一种服务。如果节点上不存在端点,流量则被丢弃:
191198

192199
```yaml
193200
apiVersion: v1
@@ -207,12 +214,11 @@ spec:
207214
208215
<!--
209216
### Prefer Node Local Endpoints
210-
-->
211-
### 首选节点本地端点
212217
213-
<!--
214218
A Service that prefers node local Endpoints but falls back to cluster wide endpoints if node local endpoints do not exist:
215219
-->
220+
### 首选节点本地端点
221+
216222
首选节点本地端点,如果节点本地端点不存在,则回退到集群范围端点的一种服务:
217223
218224
```yaml
@@ -234,13 +240,13 @@ spec:
234240
235241
<!--
236242
### Only Zonal or Regional Endpoints
237-
-->
238-
### 仅地域或区域端点
239-
<!--
243+
240244
A Service that prefers zonal then regional endpoints. If no endpoints exist in either, traffic is dropped.
241245
-->
242-
首选地域端点而不是区域端点的一种服务。 如果以上两种范围内均不存在端点,流量则被丢弃。
246+
### 仅地域或区域端点
243247
248+
首选地域端点而不是区域端点的一种服务。 如果以上两种范围内均不存在端点,
249+
流量则被丢弃。
244250
245251
```yaml
246252
apiVersion: v1
@@ -261,13 +267,13 @@ spec:
261267
262268
<!--
263269
### Prefer Node Local, Zonal, then Regional Endpoints
264-
-->
265-
### 优先选择节点本地端点,地域端点,然后是区域端点
266270
267-
<!--
268271
A Service that prefers node local, zonal, then regional endpoints but falls back to cluster wide endpoints.
269272
-->
270-
优先选择节点本地端点,地域端点,然后是区域端点,然后才是集群范围端点的一种服务。
273+
### 优先选择节点本地端点、地域端点,然后是区域端点
274+
275+
优先选择节点本地端点,地域端点,然后是区域端点,最后才是集群范围端点的
276+
一种服务。
271277
272278
```yaml
273279
apiVersion: v1
@@ -296,3 +302,4 @@ spec:
296302
-->
297303
* 阅读关于[启用服务拓扑](/zh/docs/tasks/administer-cluster/enabling-service-topology/)
298304
* 阅读[用服务连接应用程序](/zh/docs/concepts/services-networking/connect-applications-service/)
305+

0 commit comments

Comments
 (0)