marathon部署一套Nginx环境
要求:
Marathon有自己的REST API,我们通过API的方式来创建一个Nginx的Docker容器。
方案:
首先创建如下的配置文件nginx.json
cat nginx.json
{
"id":"nginx",
"cpus":0.2,
"mem":32.0,
"instances": 1,
"constraints": [["hostname","UNIQUE",""]],
"container": {
"type":"DOCKER",
"docker": {
"image": "nginx",
"network": "BRIDGE",
"portMappings": [
{
"containerPort": 80,
"hostPort": 0,
"servicePort": 0,
"protocol":"tcp"
}
]
}
},
"healthChecks": [
{
"protocol": "HTTP",
"portIndex": 0,
"path": "/",
"gracePeriodSeconds": 5,
"intervalSeconds": 20,
"maxConsecutiveFailures": 3
}
]
}
测试:
通过marathon提供的端口能访问Nginx默认页面
说明:
1.通过marathon部署一个Nginx
2.通过浏览器或命令行能够访问Nginx的默认首页
3.用以验证前端项目能够用marathon+mesos的方式管理
4.具体命令中的参数意义,后续文章中会逐步讲解