Regex based routing for linkerd


#1

Issue type Feature request
linkerd-version: 1.5.1

We have a requirement of routing linkerd based on an ip-range,

Btw, I added a custom header, clientIp using io.l5d.header.token

curl -H "clientIp: 127.0.0.1:8080" http://<l5d-service>:4140

Scenario

Say I have two services serivceA & serviceB, I want to route them based on an ip-range, for instance,

  • IPs ranging from 127.0.0.1 to 127.0.0.5 should route to serviceA &
  • IPs ranging from 127.0.0.6 to 127.0.0.9 should route to serviceB

I believe that the above scenario can be achieved by hardcoding the ip-range to serviceA & B, but if the ip-range is large then we should be using something like regular expressions, As per my knowledge, DTABS support only wildcards like * (asterisk).

Is it possible to achieve this goal using existing linkerd’s configuration or can this be achieved by other means? This feature will be really beneficial for us.

Thanks in advance!


#2

Hi @zshaik!

The way to accomplish this would be to use a custom identifier plugin. Your plugin could use a regex (or any other means of identifying ip ranges) to map requests with clientIp header with an IP in one range to the serviceA name and requests with clientIp header in another range to the serviceB name.

You would not be able to encode this just using the standard Linkerd identifiers and dtabs.

Hope this helps!


#3

Sounds interesting, will dig into it. Thank you @Alex