bobrik / marathoner

Service discovery for marathon
26 stars 5 forks source link

Marathoner

Marathoner is a service discovery for marathon. It publishes service ports from marathon on desired interface so you always talk to 127.0.0.1 and known port. It manages haproxy and ensures that configuration is updated as soon as there are changes in running marathon tasks.

Marathoner consists of two parts:

You would probably want to run 3-5 updaters (one per marathon server) and listeners on each node for high availability.

You can also run optional logger to log every state change that happens.

Ascii view


        +---------+   +---------+   +---------+
        |marathon1|   |marathon2|   |marathon3|
        +----^----+   +----^----+   +----^----+
             |             |             |
             |             |             |
             ^-------------^-------------^  polling random alive marathon
             |             |             |
         +---+---+     +---+---+     +---+---+
         |updater|     |updater|     |updater|
         +---+---+     +---+---+     +---+---+
             |             |             |
             |             |             |  pushing to every connected client
             |             |             |
       +-----v------+------v------+------v------+
       |            |             |             |
       |            |             |             |
  +----v----+  +----v----+   +----v----+   +----v----+
  |listener1|  |listener1|   |listener1|   |listener1|
  +----+----+  +----+----+   +----+----+   +----+----+
       |            |             |             |
       |            |             |             |  reloading local haproxy
       |            |             |             |
   +---v---+    +---v---+     +---v---+     +---v---+
   |haproxy|    |haproxy|     |haproxy|     |haproxy|
   +---^---+    +---^---+     +---^---+     +---^---+
       |            |             |             |
       |            |             |             |  apps talk to local haproxy
       |            |             |             |
     +-+-+        +-+-+         +-+-+         +-+-+
     |app|        |app|         |app|         |app|
     +---+        +---+         +---+         +---+

Features

Usage

Marathoner is designed to run in docker containers.

Updater

The following command runs marathoner updater with update interval of 1 second and two marathon hosts. Updater is reachable at port 7676.

docker run -d -p 7676:7676 bobrik/marathoner-updater:1.10 \
  -m http://marathon1:8080,http://marathon2:8080 -i 1

Listener

The following command runs marathoner listener with two updaters and publishes apps on 127.0.0.1. Notice that you need to run listener with --net=host.

docker run -d --net=host bobrik/marathoner-listener:1.10 \
  -u marathoner-updater1:7676,marathoner-updater2:7676 -b 127.0.0.1

Logger

The following command runs marathoner logger with specified updater and logs state changes to stdout:

docker run --rm bobrik/marathoner-logger:1.10 -u marathoner-updater1:7676

Exposing apps

Marathon apps that needs to be exported should have label marathoner_haproxy_enabled set to true.

Building

If you made some changes and wish to check how they work, ./containers/make.sh could help you with building containers. Just run:

# build listener image with the name my-listener
./containers/make.sh listener my-listener

# build updater image with the name my-updater
./containers/make.sh updater my-updater

# build logger image with the name my-logger
./containers/make.sh updater my-logger

Version history

TODO