Skip to content

Commit 8f39ddc

Browse files
authored
[zh] Sync #16949 locality failover example to the ambient multicluster docs into Chinese (#16971)
* Sync #16949 locality failover example to the ambient multicluster docs into Chinese * Sync #16995 fixs
1 parent c78a5e3 commit 8f39ddc

File tree

3 files changed

+215
-12
lines changed

3 files changed

+215
-12
lines changed

content/zh/docs/ambient/install/multicluster/_index.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,56 @@ Istio {{< gloss "ambient" >}}Ambient 服务网格{{< /gloss >}}。
2020
此功能正在积极开发中,建议不要在生产环境中使用。
2121
{{< /warning >}}
2222

23-
在继续进行 Ambient 多集群安装之前,了解此功能的当前状态和限制至关重要:
24-
25-
### 支持的配置 {#supported-configurations}
26-
27-
目前,Ambient 多集群仅支持:在继续 Ambient 多集群安装之前,了解此功能的当前状态和限制至关重要。
23+
在进行 Ambient 多集群安装之前,了解此功能的当前状态和局限性至关重要。
2824

2925
### 关键限制 {#critical-limitations}
3026

3127
#### 网络拓扑限制 {#network-topology-restrictions}
3228

33-
**多集群单网络配置未经测试,可能会出现问题**
29+
多集群单网络配置未经测试,可能会出现问题:
30+
3431
- 在共享同一网络的集群之间部署 Ambient 时要小心
3532
- 仅支持多网络配置
3633

3734
#### 控制平面限制 {#control-plane-limitations}
3835

39-
**目前不支持主集群远程配置**
36+
目前不支持主集群远程配置:
37+
4038
- 您只能拥有多个主集群
4139
- 具有一个或多个远程集群的配置将无法正常工作
4240

4341
#### waypoint 要求 {#waypoint-requirements}
4442

45-
**假设跨集群部署通用 waypoint**
43+
假设跨集群部署通用 waypoint:
44+
4645
- 所有集群必须具有相同名称的 waypoint 部署
4746
- waypoint 配置必须跨集群手动同步(例如使用 Flux、ArgoCD 或类似工具)
4847
- 流量路由依赖于一致的 waypoint 命名约定
4948

5049
#### 服务可见性和范围 {#service-visibility-and-scoping}
5150

52-
**服务范围配置无法跨集群读取**
51+
服务范围配置无法跨集群读取:
52+
5353
- 仅使用本地集群的服务范围配置作为真实来源
5454
- 不遵循远程集群服务范围,这可能导致意外的流量行为
5555
- 跨集群服务发现可能不遵循预期的服务边界
5656

57-
**如果服务的 waypoint 被标记为全局,则该服务也将是全局的**
57+
如果服务的 waypoint 被标记为全局,则该服务也将是全局的:
58+
5859
- 如果不仔细管理,这可能会导致意外的跨集群流量
60+
- 此问题的解决方案跟踪记录在[这里](https://github.com/istio/istio/issues/57710)
61+
62+
#### 远程网络负载分配 {#load-distribution-on-remote-network}
63+
64+
流向远程网络的流量在各个端点之间的分配并不均匀:
65+
66+
- 当故障转移到远程网络时,由于 HTTP 请求多路复用和连接池机制,远程网络上的单个端点可能会收到不成比例的请求数量。
67+
- 此问题的解决方案跟踪记录在[此处](https://github.com/istio/istio/issues/58039)
5968

6069
#### 网关限制 {#gateway-limitations}
6170

62-
**Ambient 东西网关目前仅支持网格内 mTLS 流量**
71+
Ambient 东西网关目前仅支持网格内 mTLS 流量:
72+
6373
- 目前无法使用 Ambient 东西向网关在网络上公开 `istiod`。您仍然可以使用经典的东西向网关来实现此目的。
6474

6575
{{< tip >}}
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
---
2+
title: 在多集群 Ambient 安装中配置故障转移行为
3+
description: 使用 waypoint 配置 Ambient 多集群网格中的异常值检测和故障转移行为。
4+
weight: 70
5+
keywords: [kubernetes,multicluster,ambient]
6+
test: yes
7+
owner: istio/wg-environments-maintainers
8+
prev: /zh/docs/ambient/install/multicluster/verify
9+
---
10+
按照本指南,使用 waypoint 代理自定义 Ambient 多集群 Istio 安装中的故障转移行为。
11+
12+
在继续操作之前,请务必按照[多集群安装指南](/zh/docs/ambient/install/multicluster)之一完成
13+
Ambient 多集群 Istio 安装,并验证安装是否正常工作。
14+
15+
在本指南中,我们将基于用于验证多集群安装的 `HelloWorld` 应用程序进行构建。
16+
我们将为 `HelloWorld` 服务配置本地故障转移,
17+
使其优先使用客户端所在集群中的端点(使用 `DestinationRule`),并部署一个 waypoint 代理来强制执行此配置。
18+
19+
## 部署 waypoint 代理 {#deploy-waypoint-proxy}
20+
21+
为了配置异常值检测并自定义服务的故障转移行为,我们需要一个 waypoint 代理。
22+
首先,将 waypoint 代理部署到网格中的每个集群:
23+
24+
{{< text bash >}}
25+
$ istioctl --context "${CTX_CLUSTER1}" waypoint apply --name waypoint --for service -n sample --wait
26+
$ istioctl --context "${CTX_CLUSTER2}" waypoint apply --name waypoint --for service -n sample --wait
27+
{{< /text >}}
28+
29+
确认集群 `cluster1` 上的 waypoint 代理部署状态:
30+
31+
{{< text bash >}}
32+
$ kubectl --context "${CTX_CLUSTER1}" get deployment waypoint --namespace sample
33+
NAME READY UP-TO-DATE AVAILABLE AGE
34+
waypoint 1/1 1 1 137m
35+
{{< /text >}}
36+
37+
确认集群 `cluster2` 上的 waypoint 代理部署状态:
38+
39+
{{< text bash >}}
40+
$ kubectl --context "${CTX_CLUSTER2}" get deployment waypoint --namespace sample
41+
NAME READY UP-TO-DATE AVAILABLE AGE
42+
waypoint 1/1 1 1 138m
43+
{{< /text >}}
44+
45+
请等待所有 waypoint 代理准备就绪。
46+
47+
在每个集群中配置 `HelloWorld` 服务以使用 waypoint 代理:
48+
49+
{{< text bash >}}
50+
$ kubectl --context "${CTX_CLUSTER1}" label svc helloworld -n sample istio.io/use-waypoint=waypoint
51+
$ kubectl --context "${CTX_CLUSTER2}" label svc helloworld -n sample istio.io/use-waypoint=waypoint
52+
{{< /text >}}
53+
54+
最后,这一步专门针对 waypoint 代理的多集群部署,将每个集群中的 waypoint
55+
代理服务标记为全局服务,就像之前对 `HelloWorld` 服务所做的那样:
56+
57+
{{< text bash >}}
58+
$ kubectl --context "${CTX_CLUSTER1}" label svc waypoint -n sample istio.io/global=true
59+
$ kubectl --context "${CTX_CLUSTER2}" label svc waypoint -n sample istio.io/global=true
60+
{{< /text >}}
61+
62+
两个集群中的 `HelloWorld` 服务现在都配置为使用 waypoint 代理,
63+
但 waypoint 代理目前还没有任何实际作用。
64+
65+
## 配置本地故障转移 {#configure-locality-failover}
66+
67+
要配置本地故障转移,请在 `cluster1` 中创建并应用 `DestinationRule`
68+
69+
{{< text bash >}}
70+
$ kubectl --context "${CTX_CLUSTER1}" apply -n sample -f - <<EOF
71+
apiVersion: networking.istio.io/v1
72+
kind: DestinationRule
73+
metadata:
74+
name: helloworld
75+
spec:
76+
host: helloworld.sample.svc.cluster.local
77+
trafficPolicy:
78+
outlierDetection:
79+
consecutive5xxErrors: 1
80+
interval: 1s
81+
baseEjectionTime: 1m
82+
loadBalancer:
83+
simple: ROUND_ROBIN
84+
localityLbSetting:
85+
enabled: true
86+
failoverPriority:
87+
- topology.istio.io/cluster
88+
EOF
89+
{{< /text >}}
90+
91+
`cluster2` 中也应用相同的 `DestinationRule`
92+
93+
{{< text bash >}}
94+
$ kubectl --context "${CTX_CLUSTER2}" apply -n sample -f - <<EOF
95+
apiVersion: networking.istio.io/v1
96+
kind: DestinationRule
97+
metadata:
98+
name: helloworld
99+
spec:
100+
host: helloworld.sample.svc.cluster.local
101+
trafficPolicy:
102+
outlierDetection:
103+
consecutive5xxErrors: 1
104+
interval: 1s
105+
baseEjectionTime: 1m
106+
loadBalancer:
107+
simple: ROUND_ROBIN
108+
localityLbSetting:
109+
enabled: true
110+
failoverPriority:
111+
- topology.istio.io/cluster
112+
EOF
113+
{{< /text >}}
114+
115+
`DestinationRule` 配置以下内容:
116+
117+
-`HelloWorld` 服务配置[异常值检测](/zh/docs/reference/config/networking/destination-rule/#OutlierDetection)
118+
此规则指示 waypoint 代理如何识别服务的端点何时出现异常。这是故障转移正常运行所必需的。
119+
120+
- [故障转移优先级](/zh/docs/reference/config/networking/destination-rule/#LocalityLoadBalancerSetting)指示
121+
waypoint 代理在路由请求时如何确定端点的优先级。在本例中,
122+
waypoint 代理将优先处理同一集群中的端点,而不是其他集群中的端点。
123+
124+
有了这些策略,当端点与 waypoint 代理位于同一集群中且根据异常值检测配置被认为运行正常时,
125+
waypoint 代理将优先选择这些端点。
126+
127+
## 验证流量是否保持在本地集群内 {#verify-traffic-stays-in-local-cluster}
128+
129+
`cluster1` 上的 `curl` Pod 向 `HelloWorld` 服务发送请求:
130+
131+
{{< text bash >}}
132+
$ kubectl exec --context "${CTX_CLUSTER1}" -n sample -c curl \
133+
"$(kubectl get pod --context "${CTX_CLUSTER1}" -n sample -l \
134+
app=curl -o jsonpath='{.items[0].metadata.name}')" \
135+
-- curl -sS helloworld.sample:5000/hello
136+
{{< /text >}}
137+
138+
现在,如果您多次重复此请求并验证 `HelloWorld` 版本应始终为 `v1`
139+
因为流量始终位于 `cluster1` 中:
140+
141+
{{< text plain >}}
142+
Hello version: v1, instance: helloworld-v1-954745fd-z6qcn
143+
Hello version: v1, instance: helloworld-v1-954745fd-z6qcn
144+
...
145+
{{< /text >}}
146+
147+
同样地,从 `cluster2` 上的 `curl` Pod 多次发送请求:
148+
149+
{{< text bash >}}
150+
$ kubectl exec --context "${CTX_CLUSTER2}" -n sample -c curl \
151+
"$(kubectl get pod --context "${CTX_CLUSTER2}" -n sample -l \
152+
app=curl -o jsonpath='{.items[0].metadata.name}')" \
153+
-- curl -sS helloworld.sample:5000/hello
154+
{{< /text >}}
155+
156+
通过查看响应中的版本信息,您应该可以看到所有请求都在 `cluster2` 中处理:
157+
158+
{{< text plain >}}
159+
Hello version: v2, instance: helloworld-v2-7b768b9bbd-7zftm
160+
Hello version: v2, instance: helloworld-v2-7b768b9bbd-7zftm
161+
...
162+
{{< /text >}}
163+
164+
## 验证故障转移到另一个集群 {#verify-failover-to-another-cluster}
165+
166+
为了验证故障转移到从集群是否有效,通过缩减部署规模来模拟
167+
`cluster1` 中的 `HelloWorld` 服务中断:
168+
169+
{{< text bash >}}
170+
$ kubectl --context "${CTX_CLUSTER1}" scale --replicas=0 deployment/helloworld-v1 -n sample
171+
{{< /text >}}
172+
173+
再次从 `cluster1` 上的 `curl` Pod 向 `HelloWorld` 服务发送请求:
174+
175+
{{< text bash >}}
176+
$ kubectl exec --context "${CTX_CLUSTER1}" -n sample -c curl \
177+
"$(kubectl get pod --context "${CTX_CLUSTER1}" -n sample -l \
178+
app=curl -o jsonpath='{.items[0].metadata.name}')" \
179+
-- curl -sS helloworld.sample:5000/hello
180+
{{< /text >}}
181+
182+
这次您应该会看到请求是由 `cluster2` 中的 `HelloWorld` 服务处理的,
183+
因为 `cluster1` 中没有可用的端点:
184+
185+
{{< text plain >}}
186+
Hello version: v2, instance: helloworld-v2-7b768b9bbd-7zftm
187+
Hello version: v2, instance: helloworld-v2-7b768b9bbd-7zftm
188+
...
189+
{{< /text >}}
190+
191+
**恭喜!**您已成功的在 Istio Ambient 多集群部署中配置本地故障转移!

content/zh/docs/ambient/install/multicluster/verify/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,6 @@ Hello version: v1, instance: helloworld-v1-86f77cd7bd-cpxhv
204204

205205
**恭喜!**您已成功在多个集群上安装并验证了 Istio!
206206

207-
<!-- TODO: Link to guide for locality load balancing once we add waypoint instructions -->
207+
## 后续步骤 {#next-steps}
208+
209+
为您的多集群部署配置[本地故障转移](/zh/docs/ambient/install/multicluster/failover)

0 commit comments

Comments
 (0)