我已经设置了DCOS 1.8群集,目前我正在熟悉。 到目前为止,我的marathon-lb像Jenkins通过Host网络一样工作。现在我正在尝试使用Overlay进行设置。 我有几个测试容器,一些在dcos覆盖网络中,有些则没有。到目前为止,他们可以通过IP达到彼此,这很好。但是,当我尝试使用mesos-dns在覆盖网络上解析容器时,所有它解析的都是主机地址(不完全是我所期待的)。
所以我和马拉松一起玩了一些人来解决这个问题。我所做的是向ipAddress添加一个发现块:
{
"volumes": null,
"id": "/mariadb10",
"cmd": null,
"args": null,
"user": null,
"env": {
"MYSQL_ROOT_PASSWORD": "foo"
},
"instances": 1,
"cpus": 1,
"mem": 1024,
"disk": 0,
"gpus": 0,
"executor": null,
"constraints": null,
"fetch": null,
"storeUrls": null,
"backoffSeconds": 1,
"backoffFactor": 1.15,
"maxLaunchDelaySeconds": 3600,
"container": {
"docker": {
"image": "mariadb:10.0",
"forcePullImage": false,
"privileged": false,
"network": "USER"
},
"type": "DOCKER",
"volumes": [
{
"containerPath": "/var/lib/mysql",
"hostPath": "/mnt/foo",
"mode": "RW"
}
]
},
"healthChecks": [
{
"protocol": "TCP",
"gracePeriodSeconds": 30,
"intervalSeconds": 10,
"timeoutSeconds": 10,
"maxConsecutiveFailures": 3,
"port": 3306
}
],
"readinessChecks": null,
"dependencies": null,
"upgradeStrategy": {
"minimumHealthCapacity": 1,
"maximumOverCapacity": 1
},
"labels": null,
"acceptedResourceRoles": null,
"ipAddress": {
"networkName": "dcos",
"discovery": {
"ports": [
{ "number": 3306, "name": "mysql", "protocol": "tcp" }
]
}
},
"residency": null,
"secrets": null,
"taskKillGracePeriodSeconds": null
}
马拉松告诉我这不允许与#34; Bridge"或"用户"网络。然而它并没有抱怨以下内容并启动了容器:
{
"volumes": null,
"id": "/mariadb10",
"cmd": null,
"args": null,
"user": null,
"env": {
"MYSQL_ROOT_PASSWORD": "foo"
},
"instances": 1,
"cpus": 1,
"mem": 1024,
"disk": 0,
"gpus": 0,
"executor": null,
"constraints": null,
"fetch": null,
"storeUrls": null,
"backoffSeconds": 1,
"backoffFactor": 1.15,
"maxLaunchDelaySeconds": 3600,
"container": {
"docker": {
"image": "mariadb:10.0",
"forcePullImage": false,
"privileged": false,
"network": "USER"
},
"type": "DOCKER",
"volumes": [
{
"containerPath": "/var/lib/mysql",
"hostPath": "/mnt/foo",
"mode": "RW"
}
]
},
"healthChecks": [
{
"protocol": "TCP",
"gracePeriodSeconds": 30,
"intervalSeconds": 10,
"timeoutSeconds": 10,
"maxConsecutiveFailures": 3,
"port": 3306
}
],
"readinessChecks": null,
"dependencies": null,
"upgradeStrategy": {
"minimumHealthCapacity": 1,
"maximumOverCapacity": 1
},
"labels": null,
"acceptedResourceRoles": null,
"ipAddress": {
"networkName": "dcos"
},
"residency": null,
"secrets": null,
"taskKillGracePeriodSeconds": null
}
有趣的是,它不再使用覆盖地址,但现在侦听主机地址,并将主机地址通知到覆盖网络。
我只是做错了还是没有按预期工作呢?
答案 0 :(得分:1)
所以,
我自己找到了解决方案。简单的解决方法是编辑/opt/mesosphere/etc/mesos-dns.json
。然后将IPSources的顺序更改为首先列出netinfo。
有关详细信息,您还可以查看here
答案 1 :(得分:0)
或者,您可以使用taskname.marathon.containerip.dcos.thisdcos.directory
。这里记录了:https://docs.mesosphere.com/1.8/administration/overlay-networks/。