Matching domains to services

I have domains pointing to linkerd and am trying to match them to services. I want to route the domain {myservice}.dev.in.mydomain.com to myservice registered in consul.

I’ve been looking into domainToPathPfx and subdomainOfPfx but am a little confused on their usage. So far I have a configuration like:

namers:
- kind: io.l5d.consul
  host: myconsul.com
  port: 8500
  prefix: /dev
  useHealthCheck: true

- protocol: http
  servers:
  - port: 80
    ip: 0.0.0.0
  dtab: |
    /domain/com/mydomain/in/dev => /#/dev;
    /host => /$/io.buoyant.http.domainToPathPfx/domain;
    /svc => /host;
  identifier:
    kind: io.l5d.methodAndHost

How do I set up the linkerd configuration to route domains like {myservice1}.dev.in.mydomain.com and {myservice1}.dev.in.mydomain.com to their associated services in consul?

I worked out the solution:

namers:
- kind: io.l5d.consul
  host: myconsul.com
  port: 8500
  prefix: /dev
  useHealthCheck: true

- protocol: http
  servers:
  - port: 80
    ip: 0.0.0.0
  dtab: |
    /consul => /#/dev/dc1;
    /svc => /$/io.buoyant.http.subdomainOfPfx/dev.mydomain.com/consul;
  identifier:
    kind: io.l5d.header.token

@summatix Unless you want to route requests based on http method, you may not want to specify io.l5d.methodAndHost, but instead rely on the default io.l5d.header.token.

Thanks. I have the routing working, but now I’m struggling with a rewrite rule. Is there a way to rewrite {myservice1}.dev.in.mydomain.com as myservice1.suffix?

Solved the rewriting with:

namers:
- kind: io.l5d.consul
  host: myconsul.com
  port: 8500
  prefix: /dev
  useHealthCheck: true
- kind: io.l5d.rewrite
  prefix: /rewrite-suffix
  pattern: "/{service}"
  name: "/consul/{service}.suffix"

- protocol: http
  servers:
  - port: 80
    ip: 0.0.0.0
  dtab: |
    /consul => /#/dev/dc1;
    /rewrite => /#/rewrite-suffix;
    /svc => /$/io.buoyant.http.subdomainOfPfx/dev.mydomain.com/rewrite;
  identifier:
    kind: io.l5d.header.token

Awesome, glad you figured it out!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.