Careful!

You are browsing documentation for a version of Kuma that is not the latest release.

MeshGatewayRoute

MeshGatewayRoute is a policy used to configure Kuma’s builtin gateway. It is used in combination with MeshGateway.

MeshGatewayRoute is a Kuma dataplane policy that replaces TrafficRoute for Kuma Gateway. It configures how a gateway should process network traffic. At the moment, it targets HTTP routing use cases. MeshGatewayRoutes are attached to gateways by matching their selector to the MeshGateway listener tags. This requires the kuma.io/service tag and, optionally, additional tags to match specific MeshGateway listeners.

The following MeshGatewayRoute routes traffic to the backend service and attaches to any listeners tagged with vhost=foo.example.com that attach to builtin gateways with kuma.io/service: edge-gateway.

type: MeshGatewayRoute
mesh: default
name: foo.example.com-backend 
selectors:
- match:
    kuma.io/service: edge-gateway
    vhost: foo.example.com
conf:
  http:
    rules:
      - matches:
          - path:
              match: PREFIX
              value: /
        backends:
          - destination:
              kuma.io/service: backend

Listener tags

When Kuma binds a MeshGatewayRoute to a MeshGateway, careful specification of tags lets you control whether the MeshGatewayRoute will bind to one or more of the listeners declared on the MeshGateway.

Each listener stanza on a MeshGateway has a set of tags; Kuma creates the listener tags by combining these tags with the tags from the underlying builtin gateway Dataplane. A selector that matches only on the kuma.io/service tag will bind to all listeners on the MeshGateway, but a selector that includes listener tags will only bind to matching listeners. One application of this mechanism is to inject standard routes into all virtual hosts, without the need to modify MeshGatewayRoutes that configure specific applications.

Matching

MeshGatewayRoute allows HTTP requests to be matched by various criteria (for example uri path, HTTP headers). When Kuma generates the final Envoy configuration for a builtin gateway Dataplane, it combines all the matching MeshGatewayRoutes into a single set of routing tables, partitioned by the virtual hostname, which is specified either in the MeshGateway listener or in the MeshGatewayRoute.

Kuma sorts the rules in each table by specificity, so that routes with more specific match criteria are always ordered first. For example, a rule that matches on a HTTP header and a path is more specific than one that matches only on path, and the longest match path will be considered more specific. This ordering allows Kuma to combine routing rules from multiple MeshGatewayRoute resources and still produce predictable results.

Filters

Every rule can include filters that further modifies requests. For example, by modifying headers and mirroring, redirecting, or rewriting requests.

For example, the following filters match /prefix, trim it from the path and set the Host header:

...
        - matches:
          - path:
              match: PREFIX
              value: /prefix/
          backends:
          - destination:
              kuma.io/service: backend
          filters:
          - requestHeader:
              set:
              - name: Host
                value: test.com
          - rewrite:
              replacePrefixMatch: "/"

Reference

conf object → Conf
HTTP routes are valid for listeners that accept HTTP/1.1 and HTTP/2 over both TCP and TLS.
Rules specifies how the gateway should match and process HTTP requests.
Backends is the set of services to which the gateway will forward requests. If a redirect filter is ...
destination object
Destination is a selector to match the individual endpoints to which the gateway will forward.
weight integer
Weight is the proportion of requests this backend will receive when a forwarding rules specifies mul...
Filters are request processing steps that are applied to matched requests. If the redirect filter is...
The mirror filter sends a percentage of HTTP requests to the given backend. The gateway ignores any ...
Backend selects a target for HTTP request forwarding.
destination object
Destination is a selector to match the individual endpoints to which the gateway will forward.
weight integer
Weight is the proportion of requests this backend will receive when a forwarding rules specifies mul...
percentage number
Percentage specifies the percentage of requests to mirror to the backend (in the range 0.0 - 100.0, ...
The redirect filter responds to the HTTP request immediately, without forwarding it to any backend. ...
hostname string
The hostname to redirect to.
host_to_backend_hostname boolean
Option to indicate that during forwarding, the host header should be swapped with the hostname of th...
replace_full string
replace_prefix_match string
Note that rewriting "/prefix" to "/" will do the right thing: - the path "/prefix" is rewritten to "...
port integer
The port to redirect to.
scheme string
The scheme for the redirect URL. Usually "http" or "https".
status_code integer
The HTTP response status code. This must be in the range 300 - 308.
name string
value string
remove array
name string
value string
name string
value string
remove array
name string
value string
host_to_backend_hostname boolean
Option to indicate that during forwarding, the host header should be swapped with the hostname of th...
replace_full string
replace_prefix_match string
Note that rewriting "/prefix" to "/" will do the right thing: - the path "/prefix" is rewritten to "...
Matches are checked in order. If any match is successful, the rule is selected (OR semantics).
match enum
Values: EXACT | REGEX | ABSENT | PRESENT
name string
Name of the HTTP header containing the value to match.
value string
Value that the HTTP header value should be matched against.
method enum
Values: NONE | CONNECT | DELETE | GET | HEAD | OPTIONS | PATCH | POST | PUT | TRACE
Path matches may be "EXACT", "PREFIX", or "REGEX" matches. If the match type is not specified, "EXAC...
match enum
Values: EXACT | PREFIX | REGEX
value string
Value is the path to match against. For EXACT and PREFIX match types, it must be a HTTP URI path. Fo...
match enum
Values: EXACT | REGEX
name string
Name of the query parameter containing the value to match.
value string
Value that the query parameter value should be matched against.
hostnames array
Hostnames lists the server names for which this route is valid. The hostnames are matched against th...
TCP routes are valid for listeners that accept connections over TCP.
destination object
Destination is a selector to match the individual endpoints to which the gateway will forward.
weight integer
Weight is the proportion of requests this backend will receive when a forwarding rules specifies mul...
selectors array
Selectors is used to match this resource to MeshGateway listener.
match object
Tags to match, can be used for both source and destinations