Envoy: Request: Lua: access and ability to make routing decisions from lua filter

Created on 12 Mar 2018  路  8Comments  路  Source: envoyproxy/envoy

Title: Lua: access to routing table and ability to make routing decisions

Description:
Our existing proxy solution is nginx+openresty. With that api we have the ability to access and make upstream selections from Lua. Now that envoy has an experimental Lua filter we'd like to evaluate replacing our nginx+openresty proxy with envoy but we are at a stand still due to existing tooling requiring this ability.

This feature request is specifically requesting the ability, from lua, to inspect the available clusters, routes, and make decisions from within the filter.

[optional Relevant Links:]

enhancement help wanted

All 8 comments

@rshriram do you think this one is also related with: envoyproxy/data-plane-api#540?

@taion809 do you have ideas what should the API look like? Does something like:

local config = handle:request():config()
config["routes"]
config["clusters"]

works?

This is partially related. With regard to making routing decisions - that鈥檚 a bigger topic. We used to do the same stuff like you on openresty with balancer by lua. When we moved to Envoy, this was something that was explicitly absent. But it was for a good reason. It kept the routing architecture in Envoy clean and simple.

Can you show me some of your lua snippets ? Perhaps i could help transition them into the Envoy model, which while being static, works out very well.

@dio @rshriram thanks for the help, I'm talking to the teams requesting this internally. It seems the needs might be changing so I'll close this out if it turns out to be unnecessary :)

I'd be hugely interested in this for some experiments I've been doing.

I have a concrete example of where this would be useful. We don't use envoy currently, but I'm evaluating it for our setup.

The API I'm working with is a navigation service - it takes requests in the form:

/route/-122.447,37.783;-122.449,37.788

where the numbers here are longitude,latitude pairs. The service returns a description of the driving path between the two supplied coordinates.

Because the planet is pretty big, we divide the backend up into geographic regions (examples would be "north america", "europe", "asia", etc). What we'd like Envoy to be able to do would be to examine the longitude/latitude values in a request, then forward the request to a cluster that has data for that part of the world map. We want to implement in Lua the algorithm described here: http://alienryderflex.com/polygon/, supply a configuration to the filter that maps polygons to a geographic region name, and have the filter direct the request to the cluster that matches the geographic region name found.

Yes, I have the same requirement, the current project is based on the nginx + openresty, which is a dynamic reverse proxy, with set_current_peer API, it can dynamically route request a particular upstream according to the URL.

So you can already do this by setting a header in lua that you then use to route to a cluster_header on the route

@mtalbot thanks, this can probably be closed then.

Was this page helpful?
0 / 5 - 0 ratings