Route Forwarding
Last updated
Was this helpful?
Last updated
Was this helpful?
Route forwarding pertains to how a sidecar should handle traffic to get to the next top. In Grey Matter, every incoming request that "matches" a route based on its and any configured is forwarded to a specified cluster.
Attribute
Description
Type
Default
shared_rules.default
Defines the types of traffic the shared rules will serve to the specified upstream clusters.
{}
shared_rules.rules
[]
route.rules
[]
route.response_data
Metadata added to the response
{}
shared_rules.response_data
Metadata added to the response
{}
In both routes and shared_rules theresponse_data
field has the following values:
Attribute
Description
Type
Default
response_data.headers
[]
response_data.cookies
[]
With metadata matching configured, the cluster constraint will look something like the following:
This configuration is telling any route using this cluster forwarding constraint to only route to instances in the cluster "example-service"
that contain the metadata key "stage"
with value "prod"
.
When a request is routed to the cluster with a metadata matcher configured, the load balancer looks for hosts in the subset with keys matching that of the metadata matcher on the request, compares their values, and routes accordingly. The load balancer subset config created for the cluster with key example-service
will look like the following:
Note that in the implementation, because the fallback policy on the upstream cluster is
ANY_ENDPOINT
, this configuration will not actually block requests from being sent to an instance that doesn't match the metadata criteria.
JSON
map of constraintType :
List of applied to to decide to the upstream cluster target
Array of
List of applied to to decide to the upstream cluster target
Array of
The Grey Matter shared rules object has a required that specifies a cluster constraint. The values configured in that constraint serve as the default cluster forwarding rules for any route with shared_rules_key
linking to that shared rules object. Thus, if no cluster constraints are configured in the , all requests matched to the route will be forwarded using this default
cluster constraint.
Each set on a Grey Matter route has an optional field constraints
. This field takes a cluster constraint object identical to the one for default
in the shared rules object. If a rule is configured with a specified constraint
, any request matching this route will be forwarded to the clusters configured in this field. See the documentation for information on more complex traffic configurations.
Adds a set of response headers and/or cookies to be added to responses when the given is sent requests.
Response data can be configured directly on the Grey Matter , or in the response_data
field in any cluster constraint object set on a or object. All response data set in any of the above ways is merged to generate the response data added to the weighted cluster.
a list of header added to headers of response
Array of
a list of cookie added to cookies of the response
Array of
Envoy can be configured with to divide hosts within an upstream cluster into subsets based on the metadata attached to the hosts. Routes can also be configured with to determine which instance within the cluster to send traffic to. This will take the one step further, and allow the mesh to specify not only which incoming requests should route to a specific cluster, but which incoming requests route to a specific instance of a cluster.
When an incoming request matches a route, the route will only send its requests to the instances within the that contain the same required metadata.
Metadata matching is configured on the cluster constraint used for forwarding a route. As described , this is either configured using the set on a Grey Matter route, or the set on a Grey Matter shared rules, or (by default) the field set on the shared rules object.
Subset load balancing will be enabled on the cluster by setting the on the upstream cluster with key matching cluster_key
in the constraint. The load balancer subset config on the cluster will have a fallback policy of "ANY_ENDPOINT"
, which means that if there is no host in the cluster meeting the metadata match criteria, any other host endpoint will be used. With subset load balancing enabled, the subset config keeps track of which hosts in the cluster contain what metadata, and groups them accordingly by their keys.
Metadata matching will then also be configured on this route. The metadata match criteria set on the created by this constraint will now set the envoy.lb
filter to look for metadata with key stage
and value prod
when considering upstream hosts for load balancing.