generic proxy: virtual host support for the generic proxy routing (#26932)

* update proto api of generic proxy

Signed-off-by: wbpcode <wangbaiping@corp.netease.com>

* update comment

Signed-off-by: wbpcode <wangbaiping@corp.netease.com>

* initial common matcher

Signed-off-by: wbpcode <wangbaiping@corp.netease.com>

* complete test

Signed-off-by: wbpcode <wangbaiping@corp.netease.com>

* minor update of new custom matcher

Signed-off-by: wbpcode <wangbaiping@corp.netease.com>

* add const to name() methods

Signed-off-by: wbpcode <wangbaiping@corp.netease.com>

* address all comments

Signed-off-by: wbpcode <wangbaiping@corp.netease.com>

* fix error after merge main

Signed-off-by: wbpcode <wangbaiping@corp.netease.com>

---------

Signed-off-by: wbpcode <wangbaiping@corp.netease.com>

Mirrored from https://github.com/envoyproxy/envoy @ d699a6329de2cd0a2c8aba88907d49cc6dcdd121
pull/626/head
data-plane-api(Azure Pipelines) 2 years ago
parent 80d04f6ed7
commit 0bb9abc1ed
  1. 4
      contrib/envoy/extensions/filters/network/generic_proxy/action/v3/action.proto
  2. 1
      contrib/envoy/extensions/filters/network/generic_proxy/matcher/v3/BUILD
  3. 53
      contrib/envoy/extensions/filters/network/generic_proxy/matcher/v3/matcher.proto
  4. 35
      contrib/envoy/extensions/filters/network/generic_proxy/v3/route.proto

@ -22,7 +22,11 @@ option (xds.annotations.v3.file_status).work_in_progress = true;
// [#protodoc-title: Generic Proxy Route Action Configuration]
// Configuration for the route match action.
// [#next-free-field: 6]
message RouteAction {
// The name of the route action. This should be unique across all route actions.
string name = 5;
oneof cluster_specifier {
option (validate.required) = true;

@ -6,6 +6,7 @@ licenses(["notice"]) # Apache 2
api_proto_package(
deps = [
"//envoy/type/matcher/v3:pkg",
"@com_github_cncf_udpa//udpa/annotations:pkg",
"@com_github_cncf_udpa//xds/annotations/v3:pkg",
],

@ -2,6 +2,8 @@ syntax = "proto3";
package envoy.extensions.filters.network.generic_proxy.matcher.v3;
import "envoy/type/matcher/v3/string.proto";
import "xds/annotations/v3/status.proto";
import "udpa/annotations/status.proto";
@ -18,17 +20,64 @@ option (xds.annotations.v3.file_status).work_in_progress = true;
// Used to match request service of the downstream request. Only applicable if a service provided
// by the application protocol.
// This is deprecated and should be replaced by HostMatchInput. This is kept for backward compatibility.
message ServiceMatchInput {
}
// Used to match request method of the downstream request. Only applicable if a method provided
// Used to match request host of the generic downstream request. Only applicable if a host provided
// by the application protocol.
// This is same with the ServiceMatchInput and this should be preferred over ServiceMatchInput.
message HostMatchInput {
}
// Used to match request path of the generic downstream request. Only applicable if a path provided
// by the application protocol.
message PathMatchInput {
}
// Used to match request method of the generic downstream request. Only applicable if a method provided
// by the application protocol.
message MethodMatchInput {
}
// Used to match an arbitrary property of the downstream request.
// Used to match an arbitrary property of the generic downstream request.
// These properties are populated by the codecs of application protocols.
message PropertyMatchInput {
// The property name to match on.
string property_name = 1 [(validate.rules).string = {min_len: 1}];
}
// [#not-implemented-hide:]
// Used to match an whole generic downstream request.
message RequestMatchInput {
}
// [#not-implemented-hide:]
// Used to match an arbitrary key-value pair for headers, trailers or properties.
message KeyValueMatchEntry {
// The key name to match on.
string name = 1 [(validate.rules).string = {min_len: 1}];
// The key value pattern.
type.matcher.v3.StringMatcher string_match = 2 [(validate.rules).message = {required: true}];
}
// [#not-implemented-hide:]
// Custom matcher to match on the generic downstream request. This is used to match
// multiple fields of the downstream request and avoid complex combinations of
// HostMatchInput, PathMatchInput, MethodMatchInput and PropertyMatchInput.
message RequestMatcher {
// Optional host pattern to match on. If not specified, any host will match.
type.matcher.v3.StringMatcher host = 1;
// Optional path pattern to match on. If not specified, any path will match.
type.matcher.v3.StringMatcher path = 2;
// Optional method pattern to match on. If not specified, any method will match.
type.matcher.v3.StringMatcher method = 3;
// Optional arbitrary properties to match on. If not specified, any properties
// will match. The key is the property name and the value is the property value
// to match on.
repeated KeyValueMatchEntry properties = 4;
}

@ -17,6 +17,32 @@ option (xds.annotations.v3.file_status).work_in_progress = true;
// [#protodoc-title: Generic Proxy Route Configuration]
message VirtualHost {
// The name of the virtual host.
string name = 1 [(validate.rules).string = {min_len: 1}];
// A list of hosts that will be matched to this virtual host. Wildcard hosts are supported in
// the suffix or prefix form.
//
// Host search order:
// 1. Exact names: ``www.foo.com``.
// 2. Suffix wildcards: ``*.foo.com`` or ``*-bar.foo.com``.
// 3. Prefix wildcards: ``foo.*`` or ``foo-*``.
// 4. Special wildcard ``*`` matching any host and will be the default virtual host.
//
// .. note::
//
// The wildcard will not match the empty string.
// e.g. ``*-bar.foo.com`` will match ``baz-bar.foo.com`` but not ``-bar.foo.com``.
// The longest wildcards match first.
// Only a single virtual host in the entire route configuration can match on ``*``. A domain
// must be unique across all virtual hosts or the config will fail to load.
repeated string hosts = 2 [(validate.rules).repeated = {min_items: 1}];
// The match tree to use when resolving route actions for incoming requests.
xds.type.matcher.v3.Matcher routes = 3 [(validate.rules).message = {required: true}];
}
// The generic proxy makes use of the `xds matching API` for routing configurations.
//
// In the below example, we combine a top level tree matcher with a linear matcher to match
@ -68,5 +94,12 @@ message RouteConfiguration {
string name = 1 [(validate.rules).string = {min_len: 1}];
// The match tree to use when resolving route actions for incoming requests.
xds.type.matcher.v3.Matcher routes = 2 [(validate.rules).message = {required: true}];
// If no any virtual host is configured in the ``virtual_hosts`` field or no special wildcard
// virtual host is configured, the ``routes`` field will be used as the default route table.
// If both the wildcard virtual host and ``routes`` are configured, the configuration will fail
// to load.
xds.type.matcher.v3.Matcher routes = 2;
// An array of virtual hosts that make up the route table.
repeated VirtualHost virtual_hosts = 3;
}

Loading…
Cancel
Save