virtualservice标头匹配
[root@k8s-master 07-headers-operation]# kubectl apply -f virtualservice-demoapp.yaml
virtualservice.networking.istio.io/demoapp configured
[root@k8s-master 07-headers-operation]# cat virtualservice-demoapp.yaml
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: demoapp
spec:
hosts:
- demoapp
http:
- name: canary
match:
- headers:
x-canary:
exact: "true"
route:
- destination:
host: demoapp
subset: v11
headers:
request:
set:
User-Agent: Chrome
response:
add:
x-canary: "true"
- name: default
headers:
response:
add:
X-Envoy: test
route:
- destination:
host: demoapp
subset: v10
直接访问demoapp默认是要v10
看下响应报文,可以看到我们自己加进来的x-envoy: test的报文,被匹配到了第二个路由规则
看下第一个路由规则
看下访问日志
kubectl logs demoappv11-77755cdc65-wxqr9 -c istio-proxy