CiscoCloud / marathon-consul

bridge Marathon information to Consul KV
Apache License 2.0
85 stars 18 forks source link

marathon-consul with consul-template example #16

Closed scalp42 closed 9 years ago

scalp42 commented 9 years ago

Any chance the repo could show an example on how to use it lets say with consul-template for example ?

I'm assuming we need to grab taskStatus in the JSON store:

{{with $t := key "marathon/TASKNAME/tasks/SUBTASKNAME" | parseJSON}}
{{if $t}}
{{$t.taskStatus}}
{{end}}
{{end}}

But how do we iterate the tasks in the KV ? marathon-consul seems to store a single key as well as a folder:

MARATHON/
  TASKNAME/
  TASKNAME

Thanks in advance for chiming in.

stevendborrelli commented 9 years ago

This is what we use in haproxy-consul:

https://github.com/CiscoCloud/haproxy-consul/blob/master/template/marathon.tmpl

Just as an FYI, we are moving towards replacing the marathon-> marathon-consul -> consul setup with traefik.

scalp42 commented 9 years ago

Thanks a lot @stevendborrelli

Any chance you could give some insight related to the move to traefik ? I'm assuming less moving parts but would love to know.

stevendborrelli commented 9 years ago

Sure:

  1. consul-template with many watches (say over 150) can take down a consul cluster
  2. There were instances where consul-template put out an invalid haproxy.cfg, and it was hard to monitor those situations. (We had to update the template to fix things like missing task id's, etc.)
  3. traefik has a UI and API
  4. dynamic reloads without having to restart haproxy and deal with possible lost connections
  5. Consul templates get complicated to write and debug as needs get more complex.
  6. It was kind of hack-ish to put discovery data in consul k/v instead of consul service discovery. We had to do this because mesos didn't expose good port mapping data. (The discoveryinfo protobufs that just landed in Mesos and mesos-consul 0.3 help here)
scalp42 commented 9 years ago

Fair enough! Greatly appreciated @stevendborrelli

scalp42 commented 9 years ago

Digging in traefik, unfortunately only http loadbalancing is supported (vs tcp mode of haproxy).