RouteFilter CRD
EnRoute Technical Reference
RouteFilter CRD
A RouteFilter
provides a mechanism to add additional routing policy logic to a Route. This may be Route that belongs to a GatewayHost
or a ServiceRoute
An example RouteFilter
to run some lua code per-route can be specified using -
apiVersion: enroute.saaras.io/v1beta1
kind: RouteFilter
metadata:
labels:
app: httpbin
name: lua-filter
namespace: httpbin
spec:
name: lua-filter
type: route_filter_lua
routeFilterConfig:
config: |
function envoy_on_request(request_handle)
request_handle:logInfo("Route Hello World request");
end
Another example is when per-route rate-limits are desired. Sending per-route state to enforce rate-limit can be created using the RouteFilter CRD
apiVersion: enroute.saaras.io/v1beta1
kind: RouteFilter
metadata:
labels:
app: httpbin
name: rl-filter
namespace: httpbin
spec:
name: rl-filter
type: route_filter_ratelimit
routeFilterConfig:
config: |
{
"descriptors" :
[
{
"remote_address": "{}"
}
]
}
RouteFilter
can be associated with a GatewayHost
by providing a list of filters:
associated with each route.
apiVersion: enroute.saaras.io/v1beta1
kind: GatewayHost
metadata:
labels:
app: httpbin
name: httpbin
namespace: httpbin
spec:
virtualhost:
fqdn: httpbin.saaraslabs.com
tls:
secretName: tls-secret-httpbin
routes:
- prefix: /
services:
- name: httpbin
port: 80
filters:
- name: rl-filter
type: route_filter_ratelimit
- name: lua-filter
type: route_filter_lua
Similarly RouteFilter
can be associated with a ServiceRoute by providing a list of filters:
associated with the route.
apiVersion: enroute.saaras.io/v1beta1
kind: ServiceRoute
metadata:
labels:
app: httpbin
name: httpbin
namespace: enroute-gw-k8s
spec:
fqdn: httpbin.saaraslabs.com
route:
conditions:
- prefix: /post
header: ":method"
exact: "POST"
services:
- name: httpbin
port: 80
filters:
- name: rl-filter
type: route_filter_ratelimit
- name: lua-filter
type: route_filter_lua
RouteFilter to Envoy configuration
RouteFilter
configuration influences the Envoy Route
and Cluster
configurations.
Envoy needs Listener
configuration to create listeners for VirtualHost
, Route
and Cluster
. By default, an ingress_http
and ingress_https
listeners are created.
Complete RouteFilter CRD Spec
A complete description of the RouteFilter
CRD spec is located in github