path-based dynamic routing to Kubernetes services

I would like to perform path-based dynamic routing to Kubernetes services with support for WebSockets.

For example, this path:
should route traffic to service my service at named port my port (namespace default) with path foo.

I got close to achieving this with Linkerd using the following ConfiMap router entry (using the io.l5d.k8s namer):


  • protocol: http
    dtab: |
    /svc => /#/io.l5d.k8s/default;
    kind: io.l5d.path
    segments: 2
    consume: true
    It worked except for that I need WebSocket support which is not available in Linkerd.

I tried NGINX using regular expressions for the location and rewrite rules. This looks something like this:

location ~ ^/(.?)/.$ {
rewrite ^/(.?)/(.)$ /$2 break;
proxy_pass http://$upstream:$1;
This worked except for that NGINX does not route to services that were created after NGINX was started. I’m not sure whether this is related to DNS caching issues in nginx or to support for SRV DNS records. This scenario should work in NGINX Plus but I must rely on open source software only.

Any ideas which reverse proxy / service mesh supports dynamic routing to K8s service:port as well as WebSockets?

Edit Can this be done with Istio? It seems that one must specify a hard-coded destination in the Istio routing configuration. I can specify a regex on the source (request) but cannot use regex capture groups to specify the destination.

Thank you

1 Like

Hey @amarbl – your config looks correct for dynamic service routing in Kubernetes. You’re correct that linkerd does not support websockets. I recommend checking out linkerd-tcp, which can route any TCP connection, including websockets. It does not support the path identifier, however, since that requires knowledge of the protocol being routed.