Skip to content

dankraw/marathon-consul-playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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.

Requirements

Usage

Download the Vagrantfile and run vagrant up.

When everything is up and running the services should be available at the following locations:

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.

Example scenario

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"
        ]
    }
}

About

An easy way to experiment with marathon-consul

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published