rancher / community-catalog

Catalog entries contributed by the community
385 stars 636 forks source link

[consul-registrator] Fix multi-node deployment on Cattle #257

Open cmeury opened 8 years ago

cmeury commented 8 years ago

I had two hosts running the consul-registrator services. The registrator is passed an URL to consul: consul://consul:8500. Looking up consul in the container will return both host IPs in a round-robin fashion, meaning the services that are registered in consul often have the wrong IP adress! I found a way to fix that, but it feels a bit hacky. Wanted to document it here, so it can help other people and/or potentially be integrated into the catalog entry in one way or the other.

Instead of

 command:
   - consul://consul:8500

I added:

  entrypoint: /bin/ash
  command: -c "/sbin/apk add -U curl; /bin/registrator consul://`curl -s http://rancher-metadata/2015-12-19/self/host/agent_ip`:8500"

Important: Make sure the command is in shell form so the backquote command gets executed.

johnrengelman commented 8 years ago

actually, i think you could fix this by configuring registrator to point to the docker bridge IP. Since the consul container is binding 8500 to the host, can you try this:

command:
  - consul://172.17.0.1:8500