如何configurationMarathon-lb负载均衡在HOSTnetworking中启动的服务?

我有一个由DC / OSpipe理的集群和一个我想通过Marathon部署的dockerized服务。 我已经有了一个马拉松磅,用于服务发现和其他现有服务的负载平衡。 所有这些服务都使用BRIDGEnetworking进行部署。

新服务暴露多个端口。 端口A用于服务实例之间的通信,端口B用于接受来自世界的请求。 我想使用HOST(而不是BRIGE)networking来部署服务。

我想知道如何configuration服务的JSON为了马拉松磅负载平衡和暴露外部端口B.

我已经尝试了各种场景和configuration,但都没有工作。 我已经构build的JSON如下所示。

{ "id": "/cassandra-seed", "cpus": 1.5, "mem": 8192, "disk": 0, "instances": 1, "container": { "type": "DOCKER", "docker": { "image": "cassandra:2.2.3", "network": "HOST", "requirePorts": true, "privileged": true, "forcePullImage": false } }, "constraints": [["hostname","UNIQUE"]], "labels": { "HAPROXY_GROUP": "external" }, "portDefinitions": [ { "port": portA,"protocol": "tcp"}, { "port": portB,"protocol": "tcp"} ] } 

在Marathon文档中 ,声明了通过在portDefitions中显式定义端口B并将requirePorts设置为true,服务端口等于主机端口。 另外,我部署了一个新版本的marathon-lb,其中端口B是它的portDefinitions部分(违反了10000-10100的默认范围)。

因此,我假定通过在服务json中提供HAPROXY_GROUP标签,marathon-lb会根据需要公开端口B. 但是,这似乎并不是这样。 如果我部署服务并且curl http://marathon-lb.marathon.mesos:portB则响应是“来自服务器的空回复”。 但是,如果我curl http://physicalNodeIP:portB我可以连接到服务的一个实例。

先谢谢你。

它看起来像你需要在应用程序定义的错误部分的requirePorts 。 它应该在顶层,像这样:

 { "id": "/cassandra-seed", "cpus": 1.5, "mem": 8192, "disk": 0, "instances": 1, "container": { "type": "DOCKER", "docker": { "image": "cassandra:2.2.3", "network": "HOST", "privileged": true, "forcePullImage": false } }, "constraints": [["hostname","UNIQUE"]], "labels": { "HAPROXY_GROUP": "external" }, "requirePorts": true, "portDefinitions": [ { "port": portA,"protocol": "tcp"}, { "port": portB,"protocol": "tcp"} ] } 

作为旁注,你应该考虑使用Cassandra框架,而不是在Marathon上运行Cassandra。