Giter VIP home page Giter VIP logo

marathon-consul-playground's Introduction

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

marathon-consul-playground's People

Contributors

dankraw avatar janisz avatar

Stargazers

Kamil Warguła avatar Pawel Szymczyk avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.