Linkerd with Consul


#1

Hi. I am in the process of exploring various features linkerd provides. I also have some sidecar deployment with Consul as my service discovery. But I am not able to succeed any http requests and it always ends up in saying Host header is absent. I have tried both using setHost as false and true in the linkerd config. I have also changed my dtab accordingly. Is there anything that needs to be done other than this?


#2

Hi Prasaanth,

You’re going to have to give us a few more details. Can you give us an example curl command and the error output? Is this with Kubernetes, or Mesos, or something else?


#3

Hi William,

I am not running it on anything and am running a stand alone linkerd instance.
I tried with the following curl command setting the host to true.

"curl -H “Host:spring-boot.service.local.consul” http://HOST:IP
where spring-boot is my service name and local is my datacenter name configured with Consul.

I end up getting the following error
"io.buoyant.router.RoutingFactory$UnknownDst: Unknown destination: Request(“GET /path/to/resource”, from /127.0.0.1:54467) / Host header is absent"

How should the host header be when it is set to false?


#4

Can you share your linkerd config? When testing with a standard linkerd config I don’t see that error:

$ curl -H "Host:spring-boot.service.local.consul" http://localhost:4140
No hosts are available for /svc/spring-boot.service.local.consul, Dtab.base=[/svc=>/#/io.l5d.fs], Dtab.local=[]. Remote Info: Not Available

If you’re using the consul.yaml example from the linkerd/examples directory then you should be able to just specify the name of the service in the Host header like this:

curl -H "Host: spring-boot" http://localhost:4140

#5

Hi Alex,

The following is my linkerd config. The error occurs when using the consul namer and not with fs.

admin:
  port: 9990

namers:
- kind: io.l5d.consul
  host: 127.0.0.1
  port: 4000
  includeTag: false
  useHealthCheck: true
  setHost: false
  consistencyMode: stale

routers:
- protocol: http
  dtab: |
    /svc => /#/io.l5d.consul/local/spring-boot;
  httpAccessLog: logs/access.log
  label: int
  servers:
  - port: 4140
    ip: 0.0.0.0
  client:
    loadBalancer:
      kind: ewma
      maxEffort: 10
      decayTimeMs: 15000
    failureAccrual:
      kind: io.l5d.successRate
      successRate: 0.9
      requests: 5
      backoff:
        kind: jittered
        minMs: 5000
        maxMs: 300000
telemetry:
- kind: io.l5d.prometheus

#6

I think your dtab should be either

/svc/* => /#/io.l5d.consul/.local/spring-boot;

To send all requests to the spring-boot service or

/svc => /#/io.l5d.consul/.local;

To send requests to the service from the Host header.

Notice that the .local segment has a dot at the beginning. This is a special keyword that indicates the local DC. Then a curl command like this should work:

curl -H "Host: spring-boot" http://localhost:4140

#7

Thanks Alex. Let me try that.


#8

Great! Let me know how it goes.


#9

Hello Prasaant,
I am facing similar issue. Is it possible for you to share you sample code with me?

Regards
Saurabh