Simple ‘Hello World’ App on DC/OS

Prerequisites: You have a catch-all DNS configured for your given FQN (example: *.mesos.sudhaker.com) that resolves to public_node(s).

Install ‘external’ load balancer.

tee marathon-lb-external.json << '__EOF__'
{ "marathon-lb":{ "name": "marathon-lb-external", "instances": 1, "haproxy-group": "external", "role": "slave_public", "mem": 512, "cpus": 1} }
__EOF__
 
dcos package install --options=marathon-lb-external.json --yes marathon-lb

Install ‘internal’ load balancer (optional; not needed here).

tee marathon-lb-internal.json << '__EOF__'
{ "marathon-lb":{ "name": "marathon-lb-internal", "instances": 1, "haproxy-group": "internal", "role": "", "mem": 512, "cpus": 1, "bind-http-https": false} }
__EOF__
 
dcos package install --options=marathon-lb-internal.json --yes marathon-lb

Install application ‘hello-world’.

export FQN=mesos.sudhaker.com
tee dockercloud-hello-world.json << __EOF__
{
  "id": "dockercloud-hello-world",
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "dockercloud/hello-world",
      "network": "BRIDGE",
      "portMappings": [
        { "hostPort": 0, "containerPort": 80 }
      ],
      "forcePullImage":true
    }
  },
  "instances": 2,
  "cpus": 0.1,
  "mem": 128,
  "healthChecks": [{
      "protocol": "HTTP",
      "path": "/",
      "portIndex": 0,
      "timeoutSeconds": 10,
      "gracePeriodSeconds": 10,
      "intervalSeconds": 2,
      "maxConsecutiveFailures": 10
  }],
  "labels":{
    "HAPROXY_GROUP":"external",
    "HAPROXY_0_VHOST":"dockercloud-hello-world.${FQN}"
  }
}
__EOF__
 
dcos marathon app add dockercloud-hello-world.json

Browse to http://dockercloud-hello-world.${FQN}

dockercloud-hello-world

Leave a Reply

Your email address will not be published. Required fields are marked *