tags: [consul, linkerd]
This post looks at how you can configure linkerd to use consul as a service discovery backend
Part of a series on linkerd:
* Part one linkerd and consul
Sample overview
The following components make up the sample system:
* curl
which acts as our client application
* linkerd
for proxying requests to our service
* audit
example service which has a /health
endpoint
* consul
as our service discovery back-end
* consul-registrator
to automatically registers services with consul
System overview
+--------+ +---------+ +-----------------+
| client +----> | linkerd +--> | service (audit) |
+--------+ +----^----+ +-------+---------+
| |
+----+---+ +-------v------------+
| consul <-----+ consul registrator |
+--------+ +--------------------+
1. Look up a consul service by path
The sample code for this can be found here: https://github.com/ewilde/linkerd-examples/tree/master/post-1
curl -H "Host: api.company.com" http://localhost:4140/audit/health -i
Should look up the service named audit
in the consul catalog and call the service with GET /health
Linkerd configuration
namers:
- kind: io.l5d.consul
includeTag: false
useHealthCheck: false
routers:
- protocol: http
label: /http-consul
identifier:
kind: io.l5d.path
segments: 1
consume: true
dtab: |
/svc => /#/io.l5d.consul/dc1;
servers:
- port: 4140
ip: 0.0.0.0
2. Look up a consul service by subdomain
curl -H "Host: audit.company.com" http://localhost:4140/health -i
Should look up the service named audit
in the consul catalog and call the service with GET /health
Linkerd configuration
namers:
- kind: io.l5d.consul
includeTag: false
useHealthCheck: false
routers:
- protocol: http
label: /host/http-consul
identifier:
kind: io.l5d.header.token
dtab: |
/consul => /#/io.l5d.consul/dc1;
/svc => /$/io.buoyant.http.subdomainOfPfx/company.com/consul;
servers:
- port: 4140
ip: 0.0.0.0
Written with StackEdit.