Dynamic routing at Gateway based on header value

Hello,

We are currently in the process of migrating our API gateway from Zuul to Istio Ingress Gateway and there is one edge case we are able to support in Zuul which we are struggling to find an equivalent solution for with Istio. This edge case scenario is that a service consumer can override the default routing rules we have configured for the given service by declaratively stating what version of the service they want to be routed to, and they do this by sending an “api-version” header. The value provided for the header indicates what version they want their request routed to (e.g. api-version: 2.0.4).

So using the example above, if a request came into zuul with a URL like https://api-gateway.com/foo, Zuul would ignore any route rules set up for service foo, and simply forward the request to the foo service pods that have the 2.0.4 version label.

So in essence, we are constructing the route rule in real-time as their request is being processed. From an Istio perspective, it would be like creating a Virtual Service with a destination based route rule in real-time with the “subset” value set based on the api-version header value.

Is there a creative way to implement this in Istio? Would a custom envoy filter be able to do anything to faciliate this?

Thanks for any help you can offer!

Bumping this up. We have the exact same need right now. Is there some special syntax in the subset field that can indicate a header’s value, e.g. ${api-version}, instead of a hardcoded value?

@my3sons, did you find a solution by any chance?

Thanks!