mirror of https://github.com/istio/istio.io.git
Translate /docs/tasks/traffic-management/traffic-shifting/index.md (#5361)
This commit is contained in:
parent
f2305b1dd1
commit
e93d9d50d8
|
@ -1,61 +1,52 @@
|
|||
---
|
||||
title: Traffic Shifting
|
||||
description: Shows you how to migrate traffic from an old to new version of a service.
|
||||
title: 流量转移
|
||||
description: 展示如何将流量从旧版本迁移到新版本的服务。
|
||||
weight: 30
|
||||
keywords: [traffic-management,traffic-shifting]
|
||||
aliases:
|
||||
- /docs/tasks/traffic-management/version-migration.html
|
||||
- /zh/docs/tasks/traffic-management/version-migration.html
|
||||
---
|
||||
|
||||
This task shows you how to gradually migrate traffic from one version of a
|
||||
microservice to another. For example, you might migrate traffic from an older
|
||||
version to a new version.
|
||||
本任务将向您展示如何逐步将流量从一个版本的微服务迁移到另一个版本。例如,您可以将流量从旧版本迁移到新版本。
|
||||
|
||||
A common use case is to migrate traffic gradually from one version of a microservice
|
||||
to another. In Istio, you accomplish this goal by configuring a sequence of rules
|
||||
that route a percentage of traffic to one service or another. In this task, you will send
|
||||
50% of traffic to `reviews:v1` and 50% to `reviews:v3`. Then, you will
|
||||
complete the migration by sending 100% of traffic to `reviews:v3`.
|
||||
一个常见的用例是将流量从一个版本的微服务逐渐迁移到另一个版本。在 Istio 中,您可以通过配置一系列规则来实现此目标,
|
||||
这些规则将一定百分比的流量路由到一个或另一个服务。在本任务中,您将会把 50% 的流量发送到 `reviews:v1`,另外 50% 的流量发送到 `reviews:v3`。然后,再把 100% 的流量发送到 `reviews:v3` 来完成迁移。
|
||||
|
||||
## Before you begin
|
||||
## 开始之前{#before-you-begin}
|
||||
|
||||
* Setup Istio by following the instructions in the
|
||||
[Installation guide](/docs/setup/).
|
||||
* 按照[安装指南](/zh/docs/setup/)中的说明安装 Istio。
|
||||
|
||||
* Deploy the [Bookinfo](/docs/examples/bookinfo/) sample application.
|
||||
* 部署 [Bookinfo](/zh/docs/examples/bookinfo/) 示例应用程序。
|
||||
|
||||
* Review the [Traffic Management](/docs/concepts/traffic-management) concepts doc.
|
||||
* 查看[流量管理](/zh/docs/concepts/traffic-management)概念文档。
|
||||
|
||||
## Apply weight-based routing
|
||||
## 应用基于权重的路由{#apply-weight-based-routing}
|
||||
|
||||
{{< warning >}}
|
||||
If you haven't already applied destination rules, follow the instructions in [Apply Default Destination Rules](/docs/examples/bookinfo/#apply-default-destination-rules).
|
||||
如果尚未应用目标规则,请按照[应用默认目标规则](/zh/docs/examples/bookinfo/#apply-default-destination-rules)中的说明进行操作。
|
||||
{{< /warning >}}
|
||||
|
||||
1. To get started, run this command to route all traffic to the `v1` version of
|
||||
each microservice.
|
||||
1. 首先,运行此命令将所有流量路由到各个微服务的 `v1` 版本。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl apply -f @samples/bookinfo/networking/virtual-service-all-v1.yaml@
|
||||
{{< /text >}}
|
||||
|
||||
1. Open the Bookinfo site in your browser. The URL is `http://$GATEWAY_URL/productpage`, where `$GATEWAY_URL` is the External IP address of the ingress, as explained in
|
||||
the [Bookinfo](/docs/examples/bookinfo/#determine-the-ingress-ip-and-port) doc.
|
||||
1. 在浏览器中打开 Bookinfo 站点。网址为 `http://$GATEWAY_URL/productpage`,其中 `$GATEWAY_URL` 是 ingress 的外部 IP 地址,其描述参见 [Bookinfo](/zh/docs/examples/bookinfo/#determine-the-ingress-ip-and-port) 文档。
|
||||
|
||||
Notice that the reviews part of the page displays with no rating stars, no
|
||||
matter how many times you refresh. This is because you configured Istio to route
|
||||
all traffic for the reviews service to the version `reviews:v1` and this
|
||||
version of the service does not access the star ratings service.
|
||||
请注意,不管刷新多少次,页面的评论部分都不会显示评级星号。
|
||||
这是因为 Istio 被配置为将 reviews 服务的的所有流量都路由到了 `reviews:v1` 版本,
|
||||
而该版本的服务不会访问带星级的 ratings 服务。
|
||||
|
||||
1. Transfer 50% of the traffic from `reviews:v1` to `reviews:v3` with the following command:
|
||||
1. 使用下面的命令把 50% 的流量从 `reviews:v1` 转移到 `reviews:v3`:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl apply -f @samples/bookinfo/networking/virtual-service-reviews-50-v3.yaml@
|
||||
{{< /text >}}
|
||||
|
||||
Wait a few seconds for the new rules to propagate.
|
||||
等待几秒钟以让新的规则传播到代理中生效。
|
||||
|
||||
1. Confirm the rule was replaced:
|
||||
1. 确认规则已被替换:
|
||||
|
||||
{{< text bash yaml >}}
|
||||
$ kubectl get virtualservice reviews -o yaml
|
||||
|
@ -79,43 +70,35 @@ the [Bookinfo](/docs/examples/bookinfo/#determine-the-ingress-ip-and-port) doc.
|
|||
weight: 50
|
||||
{{< /text >}}
|
||||
|
||||
1. Refresh the `/productpage` in your browser and you now see *red* colored star ratings approximately 50% of the time. This is because the `v3` version of `reviews` accesses
|
||||
the star ratings service, but the `v1` version does not.
|
||||
1. 刷新浏览器中的 `/productpage` 页面,大约有 50% 的几率会看到页面中出带 *红色* 星级的评价内容。这是因为 `v3` 版本的 `reviews` 访问了带星级评级的 `ratings` 服务,但 `v1` 版本却没有。
|
||||
|
||||
{{< tip >}}
|
||||
With the current Envoy sidecar implementation, you may need to refresh the
|
||||
`/productpage` many times --perhaps 15 or more--to see the proper distribution.
|
||||
You can modify the rules to route 90% of the traffic to `v3` to see red stars
|
||||
more often.
|
||||
在目前的 Envoy sidecar 实现中,可能需要刷新 `/productpage` 很多次--可能 15 次或更多--才能看到正确的流量分发的效果。您可以通过修改规则将 90% 的流量路由到 `v3`,这样能看到更多带红色星级的评价。
|
||||
{{< /tip >}}
|
||||
|
||||
1. Assuming you decide that the `reviews:v3` microservice is stable, you can
|
||||
route 100% of the traffic to `reviews:v3` by applying this virtual service:
|
||||
1. 如果您认为 `reviews:v3` 微服务已经稳定,你可以通过应用此 virtual service 规则将 100% 的流量路由到 `reviews:v3`:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl apply -f @samples/bookinfo/networking/virtual-service-reviews-v3.yaml@
|
||||
{{< /text >}}
|
||||
|
||||
Now when you refresh the `/productpage` you will always see book reviews
|
||||
with *red* colored star ratings for each review.
|
||||
现在,当您刷新 `/productpage` 时,您将始终看到带有 *红色* 星级评分的书评。
|
||||
|
||||
## Understanding what happened
|
||||
## 理解原理{#understanding-what-happened}
|
||||
|
||||
In this task you migrated traffic from an old to new version of the `reviews` service using Istio's weighted routing feature. Note that this is very different than doing version migration using the deployment features of container orchestration platforms, which use instance scaling to manage the traffic.
|
||||
在这项任务中,我们使用 Istio 的权重路由功能将流量从旧版本的 `reviews` 服务迁移到新版本。
|
||||
请注意,这和使用容器编排平台的部署功能来进行版本迁移完全不同,后者使用了实例扩容来对流量进行管理。
|
||||
|
||||
With Istio, you can allow the two versions of the `reviews` service to scale up and down independently, without affecting the traffic distribution between them.
|
||||
使用 Istio,两个版本的 `reviews` 服务可以独立地进行扩容和缩容,而不会影响这两个服务版本之间的流量分发。
|
||||
|
||||
For more information about version routing with autoscaling, check out the blog
|
||||
article [Canary Deployments using Istio](/blog/2017/0.1-canary/).
|
||||
如果想了解支持自动伸缩的版本路由的更多信息,请查看[使用 Istio 进行金丝雀部署](/zh/blog/2017/0.1-canary/) 。
|
||||
|
||||
## Cleanup
|
||||
## 清理{#cleanup}
|
||||
|
||||
1. Remove the application routing rules:
|
||||
1. 删除应用程序路由规则。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl delete -f @samples/bookinfo/networking/virtual-service-all-v1.yaml@
|
||||
{{< /text >}}
|
||||
|
||||
1. If you are not planning to explore any follow-on tasks, refer to the
|
||||
[Bookinfo cleanup](/docs/examples/bookinfo/#cleanup) instructions
|
||||
to shutdown the application.
|
||||
1. 如果您不打算探索任何后续任务,请参阅 [Bookinfo 清理](/zh/docs/examples/bookinfo/#cleanup)中的说明来关闭应用程序。
|
||||
|
|
Loading…
Reference in New Issue