Istio HTTPMatchRequest with Header not working

7/3/2019

It seems my header matching is being completely ignored or the headers are being modified before reaching the point where they are evaluated using my Virtual Service rules.

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: my-route-rules
spec:
  hosts:
  - mysite.com
  - api.mysite.com
  gateways:
  - istio-system/web-gateway
  - istio-system/api-gateway
  http:
  - match:
    - headers:
        Host: 
          exact: mysite.com
    route:
    - destination:
        host: web.default.svc.cluster.local
        port:
          number: 9000
  - match:
    - headers:
        Host:
          exact: api.mysite.com
    route:
    - destination:
        host: api.default.svc.cluster.local
        port:
          number: 7000

I found that routing works for one of my two services (completely ignoring my header rule even when I combine under a single match) if I use the following rule:

...
spec:
  http:
  - match:
    - uri:
        prefix: "/"
...

I assume this behaves as a "catch-all"; Definitely not the behavior I desire.

I fear I have gravely misunderstood Istio's routing concepts despite reading relevant docs over and over). Please help me figure out what's happening here.

-- Will
google-kubernetes-engine
istio
kubernetes

1 Answer

7/18/2019

You can try to setup a DestinationRule with a specific subset.

You will have to create a

kind: DestinationRule

and than adjust your VirtualService with something like that example:

    route:
    - destination:
        host: 
        subset: v2
  - route:
    - destination:
        host: 
        subset: v1

Also remember to follow those requirements as it is easy to make a mistake there.

Please let me know if that helped.

-- OhHiMark
Source: StackOverflow