builtin:route#

Gives addresses a name on the environment domain, served by the kevin proxy. It can also send traffic for a real hostname to a local address. The step creates nothing: it adds routes to the proxy.

To route a builtin:container port:

web: {uses: "builtin:container", with: {image: "nginx:alpine", expose: web: {port: 80}}}

web_route: {
    uses:  "builtin:route"
    needs: ["web"]
    with: routes: [{host: "web", address: "${needs.web.out.host_80}"}]
}

A host that starts with *. matches every subdomain, but not the name itself. This route matches a.web.<domain>, but not web.<domain>:

routes: [{host: "*.web", address: "${needs.web.out.host_80}"}]

To route a Service in a builtin:kubernetes cluster, set relay to the cluster’s relay address:

cluster: {uses: "builtin:kubernetes", with: {driver: "kind", relay: true}}
app:     {uses: "builtin:kubectl", needs: ["cluster"], with: {...}}

app_route: {
    uses:  "builtin:route"
    needs: ["cluster", "app"]
    with: {
        relay: "${needs.cluster.out.relay_addr}"
        routes: [{host: "myapp", address: "myapp.default.svc.cluster.local:80"}]
    }
}

Put the step that deploys the target in needs, so the route starts after it.

To send traffic for a real hostname to a local container, set intercept:

s3_fake: {uses: "builtin:container", with: {image: "ministackorg/ministack", expose: s3: {port: 4566}}}

s3_intercept: {
    uses:  "builtin:route"
    needs: ["s3_fake"]
    with: routes: [
        {host: "s3.amazonaws.com", address: "${needs.s3_fake.out.host_4566}", intercept: true},
        {host: "*.s3.amazonaws.com", address: "${needs.s3_fake.out.host_4566}", intercept: true},
    ]
}

examples/intercept is a complete example.

FieldTypeDefaultDescription
relaystring-The address of a relay, such as "${needs.cluster.out.relay_addr}" from a builtin:kubernetes step. Set it when the addresses are inside a cluster. Unset, the proxy connects to each address directly.
routes[...#Route]-The names that this step registers.

#Route#

FieldTypeDefaultDescription
hoststring-Required. The name to route. Without intercept, it is a subdomain of the environment domain: "myapp" routes "myapp.<domain>". With intercept, it is a full hostname, such as "s3.amazonaws.com". A leading "*." matches any subdomain but not the name itself: "*.myapp" matches "a.myapp.<domain>" but not "myapp.<domain>".
addressstring-Required. The target host:port. With relay, it is an address inside the cluster, such as "myapp.default.svc.cluster.local:80". Without relay, it is an address the host can connect to, such as a container step’s "host_<port>" output.
tlsbool-True when address expects TLS.
interceptbool-Sends traffic for the real hostname in host to address, for example to replace a cloud service with a local fake.
ports[...int]-Lists the ports that clients use to connect to host. Ports 80 and 443 are always intercepted. Has an effect only when intercept is true.
mode"mitm" | "passthrough" | "raw""mitm"Selects how the proxy handles connections to this route. "mitm" terminates TLS with a certificate from the kevin CA and forwards each request. "passthrough" forwards the client’s TLS connection unchanged, so the client checks the certificate of address; it requires tls: true. "raw" forwards the TCP connection unchanged, for a protocol that is not HTTP, such as a database protocol; it requires tls: false.

Behavior#

  • The console shows a link to each route, except for wildcard and intercept routes.
  • Safe to run again: a route replaces an earlier route for the same host.
  • Routes stay in the proxy until kevin stops.