When your app is up and running, you need a way to send traffic to it, from other applications on the same cluster, and from external clients.
There are several ways to do this:
For a detailed description of how ports work in Marathon, see Ports.
Mesos-DNS generates an SRV record for each Mesos task (including Marathon application instances) and translates these records to the IP address and port on the machine currently running each application.
Mesos-DNS is particularly useful when:
See the Mesos-DNS documentation and tutorials page for further information.
An alternative way to implement service discovery is to run a TCP/HTTP proxy on each host in the cluster and transparently forward connections to the static service port on localhost to the dynamically assigned host/port combinations of the individual Marathon application instances (running Mesos tasks). Clients simply connect to the well-known defined service port and do not need to know the implementation details of discovery. This approach is sufficient if all apps are launched through Marathon.
Marathon-lb is a Dockerized application that includes both HAProxy an application that uses Marathon’s REST API to regenerate the HAProxy configuration. It supports advanced functionality like SSL offloading, sticky connections, and VHost based load balancing, allowing you to specify virtual hosts for your Marathon applications.
When using marathon-lb, note that it is not necessary to set
true, as described in the ports documentation.
Marathon ships with a simple shell script called
haproxy-marathon-bridge, which uses Marathon’s REST API to create a config file for HAProxy. The
haproxy-marathon-bridge provides minimal functionality and is easier to understand for beginners or can serve as a starting point for a custom implementation. Note that this script is now deprecated and should not be used as-is in production. For production use, consider using Marathon-lb, above.
For a full list of HAProxy configurations, consult the HAProxy configuration docs.