Skip to content

Instantly share code, notes, and snippets.

@guenter
Created September 15, 2014 19:24
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save guenter/1ac7b1d57ac6cadbdb5b to your computer and use it in GitHub Desktop.
Save guenter/1ac7b1d57ac6cadbdb5b to your computer and use it in GitHub Desktop.
velocity

Links

Shared Cluster

Please prefix apps with your name if you use the shared cluster

Masters

Name	External IP	Internal IP 2	Location
custom-478-1f1	146.148.32.37	10.77.76.1	us-central1-a

Slaves

Name	External IP	Internal IP 2	Location
custom-478-ff1	146.148.35.2	10.27.30.65	us-central1-a
custom-478-2a7	199.223.236.93	10.196.74.164	us-central1-a
custom-478-ed4	146.148.53.73	10.16.152.251	us-central1-a
custom-478-289	146.148.49.57	10.2.99.171	us-central1-a
custom-478-18	146.148.60.84	10.12.119.200	us-central1-a
custom-478-db1	146.148.49.223	10.182.138.209	us-central1-a
custom-478-87a	146.148.52.161	10.216.248.162	us-central1-a
custom-478-c9c	146.148.53.65	10.103.163.187	us-central1-a
custom-478-ded	23.251.146.137	10.118.164.33	us-central1-a
custom-478-c06	146.148.41.64	10.154.37.244	us-central1-a
custom-478-bad	146.148.59.85	10.174.164.200	us-central1-a
custom-478-7fe	146.148.49.197	10.41.224.80	us-central1-a
custom-478-853	146.148.52.119	10.130.87.3	us-central1-a
custom-478-3c6	23.251.152.58	10.166.94.65	us-central1-a
custom-478-825	146.148.50.146	10.199.220.7	us-central1-a
custom-478-39b	146.148.51.246	10.188.27.198	us-central1-a
custom-478-2c4	146.148.50.18	10.3.165.226	us-central1-a
custom-478-9b1	146.148.48.92	10.217.146.102	us-central1-a

Commands

Marathon accepts JSON. The easiest way to send JSON documnets is to use cURL.

Save the JSON below to a file named app.json.

Launch an app in a Docker

{
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "superguenter/demo-app"
    }
  },
  "cmd": "rails server -p $PORT",
  "id": "rails-demo",
  "instances": 1,
  "cpus": 0.01,
  "mem": 256,
  "ports": [3000]
}
curl -i -X POST -H 'Content-Type: application/json' --data-binary @app.json http://146.148.32.37:8080/v2/apps

Scale up an app

We'll use the UI.

Adding a health check

{
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "superguenter/demo-app"
    }
  },
  "cmd": "rails server -p $PORT",
  "id": "rails-demo",
  "instances": 1,
  "cpus": 0.01,
  "mem": 256,
  "ports": [3000],
  "healthChecks": [
    {
      "path": "/",
      "portIndex": 0,
      "protocol": "HTTP",
      "gracePeriodSeconds": 30,
      "intervalSeconds": 30,
      "timeoutSeconds": 30,
      "maxConsecutiveFailures": 0
    }
  ]
}
{
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "superguenter/demo-app"
    }
  },
  "cmd": "python -m SimpleHTTPServer $PORT",
  "id": "python",
  "instances": 1,
  "cpus": 0.01,
  "mem": 256,
  "ports": [3000],
  "healthChecks": [
    {
      "path": "/",
      "portIndex": 0,
      "protocol": "HTTP",
      "gracePeriodSeconds": 30,
      "intervalSeconds": 30,
      "timeoutSeconds": 30,
      "maxConsecutiveFailures": 0
    }
  ]
}
curl -i -X POST -H 'Content-Type: application/json' --data-binary @app.json http://146.148.32.37:8080/v2/apps

Using constraints

{
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "superguenter/demo-app"
    }
  },
  "cmd": "rails server -p $PORT",
  "id": "rails-demo",
  "instances": 1,
  "cpus": 0.01,
  "mem": 256,
  "ports": [3000],
  "healthChecks": [
    {
      "path": "/",
      "portIndex": 0,
      "protocol": "HTTP",
      "gracePeriodSeconds": 30,
      "intervalSeconds": 30,
      "timeoutSeconds": 30,
      "maxConsecutiveFailures": 0
    }
  ],
  "constraints": [
      ["hostname", "UNIQUE"]
  ]
}
curl -i -X POST -H 'Content-Type: application/json' --data-binary @app.json http://146.148.32.37:8080/v2/apps

Groups

{
  "id" : "product",
  "apps": [
    {
      "id": "frontend",
      "cmd": "python -m SimpleHTTPServer $PORT",
      "instances": 1
    },
    {
      "id": "backend",
      "cmd": "python -m SimpleHTTPServer $PORT",
      "instances": 1
    }
  ]
}
curl -i -X POST -H 'Content-Type: application/json' --data-binary @app.json http://146.148.32.37:8080/v2/groups

Scale a group

curl -i -X PUT -H 'Content-Type: application/json' --data-binary '{ "scaleBy": 2 }' http://146.148.32.37:8080/v2/groups/product
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment