Is there any prioprity of Virtual Services applied for the same host?

I am using Istio 1.2.2 and have two namespaces.

application:

  • serviceA
  • serviceB
  • Virtual Service C -> B
    • gateway: mesh
    • host: serviceC.external.svc.cluster.local
    • destination: serviceB.application.svc.cluster.local
    • exportTo: . (same namespace)

external:

  • serviceC
  • Virtual Service C -> C
    • gateway: mesh
    • host: serviceC.external.svc.cluster.local
    • destination: serviceC.external.svc.cluster.local
    • exportTo: * (all namespaces)

Question: Which Virtual Service handles request form serviceA to serviceC.external.svc.cluster.local? Is there any priority?

Istio says “A VirtualService can only be fragmented this way if it is bound to a gateway. Host merging is not supported in sidecars.”

I’ve tried to reproduce this situation and Virtual Service C -> B handles request and routs it to ServiceB.

Can we rely on this behavior or it is undocumented?

As far I know, there’s no priority for VirtualServices defined for the same host for Sidecars. The behavior is undefined and hence not recommended.

You should define one VS for the host serviceC.external.svc.cluster.local with multiple match clauses which can route traffic to serviceB.application.svc.cluster.local or default route to serviceC.external.svc.cluster.local.

Thanks, we have dug into Istio code and found that Virtual Services with exportTo: . have priority but it is not documented.