|
1 | 1 | ---
|
2 |
| -reviewers: |
3 |
| -- johnbelamaric |
4 |
| -- imroc |
5 |
| -title: Service 拓扑 |
| 2 | +title: 服务拓扑(Service Topology) |
6 | 3 | feature:
|
7 |
| - title: Service 拓扑 |
| 4 | + title: 服务拓扑(Service Topology) |
8 | 5 | description: >
|
9 | 6 | 基于集群拓扑的服务流量路由。
|
10 | 7 |
|
11 | 8 | content_type: concept
|
12 | 9 | weight: 10
|
13 | 10 | ---
|
| 11 | +<!-- |
| 12 | +reviewers: |
| 13 | +- johnbelamaric |
| 14 | +- imroc |
| 15 | +title: Service Topology |
| 16 | +feature: |
| 17 | + title: Service Topology |
| 18 | + description: > |
| 19 | + Routing of service traffic based upon cluster topology. |
14 | 20 |
|
| 21 | +content_type: concept |
| 22 | +weight: 10 |
| 23 | +--> |
15 | 24 |
|
16 | 25 | <!-- overview -->
|
17 | 26 |
|
@@ -160,12 +169,130 @@ traffic as follows.
|
160 | 169 |
|
161 | 170 | * 通配符:`"*"`,如果要用,则必须是拓扑键值的最后一个值。
|
162 | 171 |
|
163 |
| -## {{% heading "whatsnext" %}} |
| 172 | +<!-- |
| 173 | +## Examples |
| 174 | +--> |
| 175 | +## 示例 |
| 176 | + |
| 177 | +<!-- |
| 178 | +The following are common examples of using the Service Topology feature. |
| 179 | +--> |
| 180 | +以下是使用服务拓扑功能的常见示例。 |
| 181 | + |
| 182 | +<!-- |
| 183 | +### Only Node Local Endpoints |
| 184 | +--> |
| 185 | +### 仅节点本地端点 |
| 186 | + |
| 187 | +<!-- |
| 188 | +A Service that only routes to node local endpoints. If no endpoints exist on the node, traffic is dropped: |
| 189 | +--> |
| 190 | +仅路由到节点本地端点的一种服务。 如果节点上不存在端点,流量则被丢弃: |
| 191 | + |
| 192 | +```yaml |
| 193 | +apiVersion: v1 |
| 194 | +kind: Service |
| 195 | +metadata: |
| 196 | + name: my-service |
| 197 | +spec: |
| 198 | + selector: |
| 199 | + app: my-app |
| 200 | + ports: |
| 201 | + - protocol: TCP |
| 202 | + port: 80 |
| 203 | + targetPort: 9376 |
| 204 | + topologyKeys: |
| 205 | + - "kubernetes.io/hostname" |
| 206 | +``` |
| 207 | +
|
| 208 | +<!-- |
| 209 | +### Prefer Node Local Endpoints |
| 210 | +--> |
| 211 | +### 首选节点本地端点 |
| 212 | +
|
| 213 | +<!-- |
| 214 | +A Service that prefers node local Endpoints but falls back to cluster wide endpoints if node local endpoints do not exist: |
| 215 | +--> |
| 216 | +首选节点本地端点,如果节点本地端点不存在,则回退到集群范围端点的一种服务: |
| 217 | +
|
| 218 | +```yaml |
| 219 | +apiVersion: v1 |
| 220 | +kind: Service |
| 221 | +metadata: |
| 222 | + name: my-service |
| 223 | +spec: |
| 224 | + selector: |
| 225 | + app: my-app |
| 226 | + ports: |
| 227 | + - protocol: TCP |
| 228 | + port: 80 |
| 229 | + targetPort: 9376 |
| 230 | + topologyKeys: |
| 231 | + - "kubernetes.io/hostname" |
| 232 | + - "*" |
| 233 | +``` |
| 234 | +
|
| 235 | +<!-- |
| 236 | +### Only Zonal or Regional Endpoints |
| 237 | +--> |
| 238 | +### 仅地域或区域端点 |
| 239 | +<!-- |
| 240 | +A Service that prefers zonal then regional endpoints. If no endpoints exist in either, traffic is dropped. |
| 241 | +--> |
| 242 | +首选地域端点而不是区域端点的一种服务。 如果以上两种范围内均不存在端点,流量则被丢弃。 |
| 243 | +
|
| 244 | +
|
| 245 | +```yaml |
| 246 | +apiVersion: v1 |
| 247 | +kind: Service |
| 248 | +metadata: |
| 249 | + name: my-service |
| 250 | +spec: |
| 251 | + selector: |
| 252 | + app: my-app |
| 253 | + ports: |
| 254 | + - protocol: TCP |
| 255 | + port: 80 |
| 256 | + targetPort: 9376 |
| 257 | + topologyKeys: |
| 258 | + - "topology.kubernetes.io/zone" |
| 259 | + - "topology.kubernetes.io/region" |
| 260 | +``` |
| 261 | +
|
| 262 | +<!-- |
| 263 | +### Prefer Node Local, Zonal, then Regional Endpoints |
| 264 | +--> |
| 265 | +### 优先选择节点本地端点,地域端点,然后是区域端点 |
164 | 266 |
|
| 267 | +<!-- |
| 268 | +A Service that prefers node local, zonal, then regional endpoints but falls back to cluster wide endpoints. |
| 269 | +--> |
| 270 | +优先选择节点本地端点,地域端点,然后是区域端点,然后才是集群范围端点的一种服务。 |
| 271 | +
|
| 272 | +```yaml |
| 273 | +apiVersion: v1 |
| 274 | +kind: Service |
| 275 | +metadata: |
| 276 | + name: my-service |
| 277 | +spec: |
| 278 | + selector: |
| 279 | + app: my-app |
| 280 | + ports: |
| 281 | + - protocol: TCP |
| 282 | + port: 80 |
| 283 | + targetPort: 9376 |
| 284 | + topologyKeys: |
| 285 | + - "kubernetes.io/hostname" |
| 286 | + - "topology.kubernetes.io/zone" |
| 287 | + - "topology.kubernetes.io/region" |
| 288 | + - "*" |
| 289 | +``` |
| 290 | +
|
| 291 | +
|
| 292 | +## {{% heading "whatsnext" %}} |
165 | 293 | <!--
|
166 | 294 | * Read about [enabling Service Topology](/docs/tasks/administer-cluster/enabling-service-topology)
|
167 | 295 | * Read [Connecting Applications with Services](/docs/concepts/services-networking/connect-applications-service/)
|
168 | 296 | -->
|
169 | 297 | * 阅读关于[启用服务拓扑](/zh/docs/tasks/administer-cluster/enabling-service-topology/)
|
170 | 298 | * 阅读[用服务连接应用程序](/zh/docs/concepts/services-networking/connect-applications-service/)
|
171 |
| - |
|
0 commit comments