04-流量转移

Catalogue
  1. 1. 所有流量路由到每个服务的v1版本
  2. 2. 将流量分别路由50%到review的v1和v3版本
  3. 3. 将流量全部路由到reviews的v3版本
  4. 4. 参考资料

该任务演示怎样缓慢迁移流量从一个版本到另一个版本,如从一个老版本到新版本升级。你能配置流量到哪个版本服务的百分比。

如下演示中将会发送50%到reviews-v1,50%到reviews-v3,最后合并100%流量到reviews-v3。

所有流量路由到每个服务的v1版本

  • virtual-service-all-v1.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: productpage
spec:
hosts:
- productpage
http:
- route:
- destination:
host: productpage
subset: v1
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v1
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ratings
spec:
hosts:
- ratings
http:
- route:
- destination:
host: ratings
subset: v1
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: details
spec:
hosts:
- details
http:
- route:
- destination:
host: details
subset: v1
---

然后访问 http://bookinfo.example.com/productpage

不论如何刷新,都不会显示星标

将流量分别路由50%到review的v1和v3版本

  • virtual-service-reviews-50-v3.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v1
weight: 50
- destination:
host: reviews
subset: v3
weight: 50

然后访问 http://bookinfo.example.com/productpage

多次刷新,大约50%几率显示红色图标,50%无星图标

将流量全部路由到reviews的v3版本

  • virtual-service-reviews-v3.yaml
1
2
3
4
5
6
7
8
9
10
11
12
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v3

然后访问 http://bookinfo.example.com/productpage

多次刷新,都显示红色图标

参考资料