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

8/7/2019

I 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.

-- Sergei Komissarov
istio
kubernetes

1 Answer

8/13/2019

If I understand you correctly there are some documented materials you should check out:

  1. You need to get familiar with the Routing rule precedence.

Multiple rules for a given destination in a configuration file are evaluated in the order they appear. The first rule on the list has the highest priority.

  1. You can also use the Rules Configuration which can be setup with a specific precedence:

Multiple route rules could be applied to the same destination. The order of evaluation of rules corresponding to a given destination, when there is more than one, can be specified by setting the precedence field of the rule.

The precedence field is an optional integer value, 0 by default. Rules with higher precedence values are evaluated first. If there is more than one rule with the same precedence value the order of evaluation is undefined.

  1. I see that you are using different namespaces. You should also get familiar with Cross-namespace configuration sharing.

Please let me know if that helped.

-- OhHiMark
Source: StackOverflow