This tutorial demonstrates how to load balance a DC/OS service and set it up for access outside of the cluster.
Prerequisites
- Edge-LB is installed following the Edge-LB Installation instructions.
- The DC/OS CLI is installed and configured to communicate with the DC/OS cluster, and the
edgelb
CLI package has been installed. - At least one DC/OS private agent node, to run the load balanced service (more is preferable).
- At least one DC/OS public agent node.
-
Create a Marathon application definition containing the service. We will call it
ping.json
. It will start one instance.{ "id": "/ping", "cpus": 0.1, "mem": 32, "instances": 1, "cmd": "echo \"pong\" > index.html && python -m http.server $PORT0", "container": { "type": "DOCKER", "docker": { "image": "python:3" } }, "healthChecks": [{ "protocol": "MESOS_HTTP", "path": "/", "portIndex": 0, "gracePeriodSeconds": 5, "intervalSeconds": 10, "timeoutSeconds": 10, "maxConsecutiveFailures": 3 }], "portDefinitions": [{ "protocol": "tcp", "port": 0, "name": "pong" }], "requirePorts": true }
-
Deploy the service.
dcos marathon app add ping.json
-
Create a pool configuration name
sample-minimal.json
.{ "apiVersion": "V2", "name": "sample-minimal", "count": 1, "haproxy": { "frontends": [{ "bindPort": 80, "protocol": "HTTP", "linkBackend": { "defaultBackend": "ping-backend" } }], "backends": [{ "name": "ping-backend", "protocol": "HTTP", "services": [{ "marathon": { "serviceID": "/ping" }, "endpoint": { "portName": "pong" } }] }] } }
-
Deploy the Edge-LB configuration.
dcos edgelb create sample-minimal.json
-
After the pool and service have been deployed, access the
host-httpd
service athttp://<public-ip>/
.You can find the private IP(s) (that DC/OS was configured with) of the node(s) that the Edge-LB load balancers are running on with the following command:
dcos edgelb endpoints sample-minimal
You can then use this information to determine the public IP that you would like to use to access the load balancer. You can also use this technique to discover public IP addresses for your cluster: Finding a Public Agent IP.