dinsdag 24 februari 2015

This is a working example how to start the open-source Cluster Manager Apache Mesos in docker with RabbitMQ as example application.

Step 1: Start  Zookeeper 
docker run \
--name zookeeper \
-d \
-p 2181:2181 \
-p 2888:2888 \
-p 3888:3888 \
jplock/zookeeper

Step 2: Start Mesos Master node 
docker run \
--name mesos_master \
--link zookeeper:zookeeper \
-d \
-e MESOS_QUORUM=1 \
-e MESOS_LOG_DIR=/var/log \
-e MESOS_WORK_DIR=/tmp \
-e MESOS_ZK=zk://zookeeper:2181/mesos \
-p 5050:5050 \
redjack/mesos-master

Step 3a: Start Mesos Slave node 01, with docker over local unix socket, or..
docker run -d \
--name mesos_slave_01 \
--link zookeeper:zookeeper \
-e MESOS_LOG_DIR=/var/log \
-e MESOS_MASTER=zk://zookeeper:2181/mesos \
-e MESOS_EXECUTOR_REGISTRATION_TIMEOUT=5mins \
-e MESOS_ISOLATOR=cgroups/cpu,cgroups/mem \
-e MESOS_CONTAINERIZERS=docker,mesos \
-v $(which docker):$(which docker) \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /sys:/sys \
-p 5051:5051 \
redjack/mesos-slave

Step 3b: Start Mesos Slave node 01, with docker over tcp socket
docker run -d \
--name mesos_slave_01 \
--link zookeeper:zookeeper \
-e MESOS_LOG_DIR=/var/log \
-e MESOS_MASTER=zk://zookeeper:2181/mesos \
-e MESOS_EXECUTOR_REGISTRATION_TIMEOUT=5mins \
-e MESOS_ISOLATOR=cgroups/cpu,cgroups/mem \
-e MESOS_CONTAINERIZERS=docker,mesos \
-v $(which docker):$(which docker) \
-e DOCKER_HOST=tcp://192.168.1.18:2375 \
-v /sys:/sys \
-p 5051:5051 \
redjack/mesos-slave

Step 4: Start Marathon to deploy docker applications in the cluster
docker run \
--name marathon \
-d \
-p 8080:8080 \
--link zookeeper:zookeeper \
mesosphere/marathon \
--master zk://zookeeper:2181/mesos \
--zk zk://zookeeper:2181/marathon

Step 5: Generate a application deployment json, in this case for RabbitMQ
{
"container": {
"type": "DOCKER",
"docker": {
"image": "rabbitmq:management",
"network": "BRIDGE",
"portMappings": [
{ "containerPort": 5672, "hostPort": 0, "servicePort": 5672, "protocol": "tcp" },
{ "containerPort": 15672, "hostPort": 0, "servicePort": 15672, "protocol": "tcp" }
]
}
},
"id": "rabbitmq",
"instances": 1,
"cpus": 0.5,
"mem": 512,
"uris": []
}
view raw rabbitmq.json hosted with ❤ by GitHub

Step 6: Upload the deployment json into the cluster, thereby starting RabbitMQ
curl \
-X POST \
-H "Content-Type: application/json" \
http://localhost:8080/v2/apps -d@rabbitmq.json

If everything went well the following pages are active:
  • http://:5050
  • http://:8080
To check where the managment page of RabbitMQ can be found, check with docker which external port is being mapped:

$ docker ps
e20b7e044e17 rabbitmq:management 0.0.0.0:31002->5672/tcp, 0.0.0.0:31003->15672/tcp mesos-4d56e476-b13e-4ac7-87ac-1b292f7cf96b

The management page can be found at:
{
"container": {
"type": "DOCKER",
"docker": {
"image": "google/cadvisor:latest"
},
"volumes": [
{
"containerPath": "/rootfs",
"hostPath": "/",
"mode": "RO"
},
{
"containerPath": "/var/run",
"hostPath": "/var/run",
"mode": "RW"
},
{
"containerPath": "/sys",
"hostPath": "/sys",
"mode": "RO"
},
{
"containerPath": "/var/lib/docker",
"hostPath": "/var/lib/docker",
"mode": "RO"
},
{
"containerPath": "/cgroup",
"hostPath": "/cgroup",
"mode": "RO"
}
],
"network": "BRIDGE",
"portMappings": [
{ "containerPort": "0.0.0.0:8080", "hostPort": "0.0.0.0:8080", "protocol": "tcp" }
]
},
"id": "cadvisor",
"instances": 1,
"cpus": 0.5,
"mem": 512,
"constraints": [
[
"hostname",
"UNIQUE"
]
],
"ports": [
8081
]
}
view raw cadvisor.json hosted with ❤ by GitHub



curl \
-X POST \
-H "Content-Type: application/json" \
http://localhost:8080/v2/apps -d@cadvisor.json
view raw cadvisor.sh hosted with ❤ by GitHub




Geen opmerkingen: