CLUSTER operator
CLUSTER allows you to run all of your app’s tasks on slaves that share a certain attribute. This
is useful for example if you have apps with special hardware needs, or if you want to run them
on the same rack for low latency.
$ curl -v -X POST http://192.168.100.30:8080/v2/apps \
-H Content-Type:application/json -d '{
"id":"dataman",
"container": {
"type": "DOCKER",
"docker": {
"image": "192.168.100.13:5000/fchen/mynginx",
"network": "BRIDGE",
"portMappings": [
{ "containerPort": 80, "hostPort": 0, "protocol": "tcp"}
]
}
},
"constraints": [["rack_id", "CLUSTER", "rack-1"]],
"cmd": "/usr/sbin/nginx -c /etc/nginx/nginx.conf",
"cpus": 0.1,
"mem": 128.0,
"instances": 5
}'
CLUSTER允许我们将app发布到Mesos特定的slave节点上。如果你的app对物理机的硬件有要
求,那么这个特性就很有用了。
我们可以看到marathon将我们的app都发布到了rack1节点上去了。
$curl -v -X POST http://192.168.100.30:8080/v2/apps \
-H Content-Type:application/json -d '{
"id":"dataman",
"container": {
"type": "DOCKER",
"docker": {
"image": "192.168.100.13:5000/fchen/mynginx",
"network": "BRIDGE",
"portMappings": [{
"containerPort": 80, "hostPort": 0, "protocol": "tcp"
}]
}
},
"constraints": [["hostname", "CLUSTER", "192.168.100.27"]],
"cmd": "/usr/sbin/nginx -c /etc/nginx/nginx.conf",
"cpus": 0.1,
"mem": 128.0,
"instances": 2
}'
我们还可以指定field name为hostname,并将optional parameter指定为我们希望app运行的slave的hostname。这样我们将2个dataman的instance发布到了192.168.100.27这台slave上。