您的位置:首页 > 大数据 > 人工智能

【云星数据---mesos实战系列】:marathon实战Constraints篇-002

2017-12-05 16:45 811 查看

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都发布到了rack­1节点上去了。



$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上。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐