'How to implement API routing with istio

My goal is to implement API routing with Istio

Assume that there are 3 services:

  • Service A
  • Service B
  • Service C

and Service A uses Service B. I want to make make Service A use Service C instead without modifying Service A.

I checked Istio docs for Traffic management, Virtual Services and Destination Rules

Istio doc says

Virtual services also let you:

Address multiple application services through a single virtual service. If your mesh uses Kubernetes, for example, you can configure a virtual service to handle all services in a specific namespace. Mapping a single virtual service to multiple “real” services is particularly useful in facilitating turning a monolithic application into a composite service built out of distinct microservices without requiring the consumers of the service to adapt to the transition. Your routing rules can specify “calls to these URIs of monolith.com go to microservice A”, and so on. You can see how this works in one of our examples below. Configure traffic rules in combination with gateways to control ingress and egress traffic.

And my understanding was that we can use Virtual Service as an abstraction layer to decouple Service A from dependency on Service B as shown below:

                                                    /--> Service B    
Service A -> Virtual Service -> Destination Rule-> |
                                                    \--> Service C

But when I started to implement POC I discovered a problem with that I can not use DNS name of Virtual Service in Service A, because VirtualService by itself does not create any DNS records.

I am confused as to what DNS name I should specify if I do not to be either with Service B or with Service C.

One thought was to create an internal ingress gateway and use its hostname, but is it really necessary? I do not want all traffic in mesh to pass through this gateway as I think it will reduce performance



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source