Code Monkey home page Code Monkey logo

mesos-marathon-demo's Introduction

Mesos-marathon demo

Preparing the environnement

Just follow the instructions inside the vagrant-mesos directory. Once your vagrant machine is running with mesos and marathon installed you can continue with the following sections.

Building the image

To be able to execute the example using docker, the directory docker-image contains the steps needed to build and create docker instances. For this example, i have pushed my image in dockerhub ant then with

docker push dicaormu/app

Then, from the vagrant machine, i have pulled the image before run with marathon using

sudo docker pull dicaormu/piopiojar

Running the image

In order to deploy a new application in marathon it is just enough to make a Http POST

curl -XPOST -H "Content-Type:application/json" "http://192.168.33.10:8080/v2/apps" -d @/Users/johndoe/Documents/mesos-marathon/app.json

The contents of the json file obviously depends on the kind of applcation we want to deploy. The following sections contains several examples.

Installing a tomcat server and deploy a war inside

curl -i -H "Content-type: application/json" -X POST http://192.168.33.10:8080/v2/apps -d '
{
  "id": "tomcat",
  "cmd": "mv *.war apache-tomcat-*/webapps && cd apache-tomcat-* && sed \"s/8080/$PORT/g\" < ./conf/server.xml > ./conf/server-mesos.xml && ./bin/catalina.sh run -config ./conf/server-mesos.xml",
  "mem": 512,
  "cpus": 1.0,
  "instances": 1,
  "uris": [
    "http://wwwftp.ciril.fr/pub/apache/tomcat/tomcat-8/v8.0.20/bin/apache-tomcat-8.0.20.tar.gz",
    "https://gwt-examples.googlecode.com/files/Calendar.war"
  ]
}
'

Installing a docker image and start it

curl -i -H "Content-type: application/json" -X POST http://192.168.33.10:8080/v2/apps -d '
{
 "id": "exampleapp",
 "instances": 1,
 "cpus": 0.25,
 "mem": 128,
 "uris":[],
 "env": {  },
 "ports":[9000],
 "container": {
   "type": "DOCKER",
   "volumes": [],
   "docker": {
     "image": "dicaormu/piopiojar:latest",
     "network": "BRIDGE",
     "portMappings": [{ "containerPort": 8080, "servicePort": 9000 , "hostPort": 0, "protocol": "tcp" }]
    }
  }
}
'

It is also possible to create additional health checks to the installed applications by adding the following section to the json

"healthChecks": [
    {
      "protocol": "HTTP",
      "portIndex": 0,
      "path": "/",
      "gracePeriodSeconds": 5,
      "intervalSeconds": 20,
      "maxConsecutiveFailures": 3
    },
    {
      "protocol": "COMMAND",
      "command": { "value": "curl -f -X GET http://$HOST:$PORT" },
      "gracePeriodSeconds": 5,
      "intervalSeconds": 20,
      "maxConsecutiveFailures": 3
    }
]

mesos-marathon-demo's People

Contributors

fagossa avatar dicaormu 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.