Playground for marathon-consul
This repository contains a Vagrantfile which makes it easy to experiment with the marathon-consul project.
It creates a virtual machine with mesos, marathon, consul and marathon-consul installed.
- Vagrant (1.7+)
- VirtualBox (4.0.x, 4.1.x, 4.2.x, 4.3.x, 5.0.x, 5.1.x)
Download the Vagrantfile and run vagrant up
.
When everything is up and running the services should be available at the following locations:
- Mesos: http://10.10.10.10:5050
- Marathon: http://10.10.10.10:8080
- Consul: http://10.10.10.10:8500
You can access the machine with vagrant ssh
and stop it with vagrant halt
.
Marathon-consul
logs are available at /var/log/upstart/marathon-consul.log
file.
Create an application in Marathon by sending a PUT
request to 10.10.10.10:8080
with some example data:
[{
"id": "/myapp",
"cmd": "python -m SimpleHTTPServer $PORT0",
"instances": 1,
"cpus": 0.1,
"mem": 16,
"disk": 0,
"executor": "",
"ports": [0],
"healthChecks": [{
"path": "/",
"protocol": "HTTP",
"portIndex": 0,
"gracePeriodSeconds": 300,
"intervalSeconds": 60,
"timeoutSeconds": 20,
"maxConsecutiveFailures": 3,
"ignoreHttp1xx": false
}],
"labels": {
"consul": "myCustomServiceName"
}
}]
If you want your registered service name to be the same as Marathon application name, pass empty string as the value of "consul" label
Example using curl
:
curl -s -X PUT -H "Content-Type: application/json" http://10.10.10.10:8080/v2/apps -d '[{"id":"/myapp","cmd":"python -m SimpleHTTPServer $PORT0","instances":1,"cpus":0.1,"mem":16,"disk":0,"executor":"","ports":[0],"healthChecks":[{"path":"/","protocol":"HTTP","portIndex":0,"gracePeriodSeconds":300,"intervalSeconds":60,"timeoutSeconds":20,"maxConsecutiveFailures":3,"ignoreHttp1xx":false}],"labels":{"consul":"myCustomServiceName"}}]' | python -m json.tool
{
"deploymentId": "898acddc-9279-4915-84a1-81cbb6bf4b0d",
"version": "2016-01-13T13:58:58.034Z"
}
Now you should be able to see it in the Marathon console at http://10.10.10.10:8080/.
When the healthcheck goes green it will be registered as a service in Consul (http://10.10.10.10:8500/):
curl -s 10.10.10.10:8500/v1/agent/services | python -m json.tool
{
"consul": {
"Address": "",
"CreateIndex": 0,
"EnableTagOverride": false,
"ID": "consul",
"ModifyIndex": 0,
"Port": 8300,
"Service": "consul",
"Tags": []
},
"myapp.cc533052-b9f8-11e5-9fc0-080027fcad58": {
"Address": "10.10.10.10",
"CreateIndex": 0,
"EnableTagOverride": false,
"ID": "myapp.cc533052-b9f8-11e5-9fc0-080027fcad58",
"ModifyIndex": 0,
"Port": 31867,
"Service": "myCustomServiceName",
"Tags": [
"marathon"
]
}
}