12.5Istio核心功能实践-智能路由
请求路由任务首先会把Bookinfo应用的流量导向reviews服务的v1版本。接下来会把特定用户的请求发送给v2版本。其他用户不受影响
应用默认目标规则
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: productpage
spec:
host: productpage
subsets:
- name: v1
labels:
version: v1
关注点:
subsets
labels:对应pod的labels
应用VirtualService
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: productpage
spec:
host:
- productpage
http:
- route:
- destination:
host:productPage
subset:v1
关注点:
subset为在DestinationRule中定义的subset
把特定用户的请求发送给v2版本
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
...
spec:
hosts:
- reviews
http:
- match:
- headers:
end-user:
exact: jason
route:
- destination:
host: reviews
subset: v2
- route:
- destination:
host: reviews
subset: v1
关注点:当headers中end-user为jason的流量将路由到v2版本
故障注入
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ratings
spec:
hosts:
- ratings
http:
- match:
- headers:
end-user:
exact: jason
fault:
delay:
percentage:
value: 100.0
fixedDelay: 7s
route:
- destination:
host: ratings
subset: v1
- route:
- destination:
host: ratings
subset: v1
注意点:
fault:
delay:
fixedDelay:设置延迟7s
流量迁移
迁移50%的流量从v1到v3
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
关注点:
weight:权重
Last updated
Was this helpful?