ServiceRoute CRD

EnRoute Technical Reference

ServiceRoute CRD

The ServiceRoute resource helps a developer define routing and policies corresponding to their service.

Configuration specified in a ServiceRoute is aggregated with a GatewayHost using FqdnA matching Fqdn associates a ServiceRoute with a GatewayHost.

apiVersion: enroute.saaras.io/v1
kind: ServiceRoute
metadata:
  name: serviceroute-httpbin-9000
  namespace: httpbin
spec:
  fqdn: 'httpbin.k8sgw.com'
  route:
    conditions:
    - prefix: /status
    services:
    - name: httpbin
      port: 9000

The key aspects of a ServiceRoute are the Fqdn, L7 route and the corresponding service

Routing in ServiceRoute (and GatewayHost) can be used to specify additional L7 route matching. Eg: the ServiceRoute above can be specified with a route that uses method in addition to the prefix can be specified as -

apiVersion: enroute.saaras.io/v1
kind: ServiceRoute
metadata:
  name: serviceroute-get-httpbin-9000
  namespace: httpbin
spec:
  fqdn: 'httpbin.k8sgw.com'
  route:
    conditions:
    - prefix: /get
      header: ":method"
      exact: "GET"
    services:
    - name: httpbin
      port: 9000

Similarly for POST, an additional ServiceRoute can be specified -

apiVersion: enroute.saaras.io/v1
kind: ServiceRoute
metadata:
  name: serviceroute-post-httpbin-9000
  namespace: httpbin
spec:
  fqdn: 'httpbin.k8sgw.com'
  route:
    conditions:
    - prefix: /post
      header: ":method"
      exact: "POST"
    services:
    - name: httpbin
      port: 9000

ServiceRoute to Envoy configuration

ServiceRoute 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 ServiceRoute CRD Spec

A complete description of the ServiceRoute CRD spec is located in github