-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
router: integrate matching API #17633
Changes from 44 commits
12ea8c9
44e162b
7c35634
0586cb1
50fe3e8
81aa2bc
7ff4d44
7acbde0
98100c7
fd00924
28bf418
f4a6292
a4b752b
41f07e4
ba371e8
0fb80ba
9d24e1f
f6d9af7
da0454b
02dc3f0
853a1bd
54079e5
7863b17
4ebb008
09c782e
199a8b1
73e1848
4c9f5e6
aae8d46
2381d38
6e5177e
0071dc8
2de2fa8
fe81ce1
90d687f
90e2332
921dcdd
6863442
0704e32
f75e539
9eedbd5
b31ef7a
2c2be12
082376d
c3149c4
82a5fdd
269954c
8083421
418a270
9d72842
694d945
50080bd
a95c67c
1d16eba
71c4c5a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,3 +192,63 @@ upon configuration load and cache the contents. | |
|
||
If **response_headers_to_add** has been set for the Route or the enclosing Virtual Host, | ||
Envoy will include the specified headers in the direct HTTP response. | ||
|
||
Routing Via Generic Matching | ||
---------------------------- | ||
|
||
Envoy recently added support for utilzing a :ref:`generic match tree <arch_overview_matching_api>` to | ||
specify the route table. This is a more expressive matching engine than the original one, allowing | ||
for sublinear matching on arbitrary headers (unlike the original matching engine which could only | ||
do this for :authority in some cases). | ||
|
||
To use the generic matching tree, specify a matcher on a virtual host with a RouteAction action: | ||
|
||
.. code-block:: yaml | ||
|
||
matcher: | ||
"@type": type.googleapis.com/xds.type.matcher.v3.Matcher | ||
matcher_tree: | ||
input: | ||
name: request-headers | ||
typed_config: | ||
"@type": type.googleapis.com/envoy.type.matcher.v3.HttpRequestHeaderMatchInput | ||
header_name: :path | ||
exact_match_map: | ||
map: | ||
"/new_endpoint/foo": | ||
action: | ||
name: route | ||
typed_config: | ||
"@type": type.googleapis.com/envoy.config.route.v3.Route | ||
match: | ||
prefix: / | ||
route: | ||
cluster: cluster_foo | ||
request_headers_to_add: | ||
- header: | ||
key: x-route-header | ||
value: new-value | ||
"/new_endpoint/bar": | ||
action: | ||
name: route | ||
typed_config: | ||
"@type": type.googleapis.com/envoy.config.route.v3.Route | ||
match: | ||
prefix: / | ||
route: | ||
cluster: cluster_bar | ||
request_headers_to_add: | ||
- header: | ||
key: x-route-header | ||
value: new-value | ||
|
||
This allows resolving the same Route proto message used for the `routes`-based routing using the additional | ||
matching flexibility provided by the generic matching framework. | ||
|
||
Note that the resulting Route also specifies a match criteria. This must be satisfied in addition to resolving | ||
the route in order to achieve a route match. When path rewrites are used, the matched path will only depend on | ||
the match criteria of the resolved Route. Path matching done during the match tree traversal does not contribute | ||
to path rewrites. | ||
|
||
The only inputs supported are request headers (via `envoy.type.matcher.v3.HttpRequestHeaderMatchInput`). See | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is this validated and what error message does the user get if they configure something else accidentally? Same question about the action config which I guess will only currently work for route proto lookup? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like this was not validated, now we are with the following error message:
For action configs the only registered factory for |
||
the docs for the :ref:`matching API <arch_overview_matching_api>` for more information about the API as a whole. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broadly agree this structure looks great. One observation I have is that making
Route
the action, rather thanRouteAction
the action is a bit unfortunate, since we have aRouteMatcher
inside of thisRoute
. Ideally it would just beRouteAction
, but these days we have a bunch of stuff such as per-route filter config, response headers to add etc. at this level (since shared with other actions). The idea of splitting match-action has kind of fallen apart (we were shooting for that in the v2 xDS RDS structure).So, what is here is fine. Maybe you could actually run the
RouteMatcher
on theRoute
you resolve to after theMatcher
match, to be able to support things like path rewrite. It's a bit redundant, but it also is O(1) and might only need to be done when you need the match criteria.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that using
Route
here seems a little counter-intuitive, but I also agree that it's totally workable.Another option would be to copy the common route fields into a
CommonRouteConfig
message, and then have each of the action types (RouteAction
,RedirectAction
, et al) include a field of typeCommonRouteConfig
. That might be a little more in the spirit of the generic matching API, where the matching action really ought to be the route action.