按权重分流

我们修改之前的 VirtualService , 添加一些权重

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: nginx-default-v2
  namespace: lizhe
spec: 
  hosts:
  - nginx-service
  http:
  - route: 
    - destination: 
        host: nginx-service
        subset: v1
      weight: 10
    - destination: 
        host: nginx-service
        subset: v2
      weight: 10
    - destination: 
        host: nginx-service
        subset: v3
      weight: 80

然后进行一下测试

for i in `seq 20`; do curl http://nginx-service/helloworld.html;echo "" ;done
Send a Message