1

I have a cluster managed by DC/OS and a dockerized service that I want to deploy through Marathon. I already have a marathon-lb that is being used for service discovery and load balancing of other existing services. All these services are deployed using BRIDGE network.

The new service exposes more than one ports. Port A is for communication between the instances of the service and port B is for accepting requests from the world. I want to use HOST (and not BRIGE) network for deploying the service.

I would like to know how to configure the json of the service in order for marathon-lb to load-balance and expose externally port B.

I have already tried various scenarios and configurations but none worked. The json that I have constructed is the below.

{
  "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"}
  ]
}

In Marathon documentation it is stated that by explicitly defining port B in portDefitions and setting requirePorts to true, service ports are equal to host port. Also, I deployed a new version of marathon-lb where port B is its portDefinitions section (violating the 10000-10100 default range).

Thus, I assumed that by providing the HAPROXY_GROUP label in the service json, marathon-lb would expose port B as desired. However, this does not seem to be the case. If I deploy the service and curl http://marathon-lb.marathon.mesos:portB the response is "Empty reply from server". However, If I curl http://physicalNodeIP:portB I can connect to an instance of the service.

Thank you in advance.

Manolis
  • 728
  • 8
  • 24
  • This question seems suspiciously similar http://stackoverflow.com/q/41586960/1305344. Anyone with more experience in DC/OS and Marathon could comment on their similarity and mark one a duplicate if they're duplicates? – Jacek Laskowski Jan 12 '17 at 12:26
  • In my point of view, they are different questions. This one refers to a configuration needed for whatever service in order to be load-balanced by Marathon-lb when deployed in HOST network mode. The stackoverflow.com/q/41586960/1305344 refers specifically to a Cassandra service, the IPs assigned to the container and the service while in HOST and BRIDGE mode and how can two Cassandra nodes gossip in each case. – Manolis Jan 13 '17 at 10:09

1 Answers1

1

It looks like you have requirePorts in the wrong section of the app definition. It should be at the top level, like this:

{
  "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"}
  ]
}

As a sidenote, you should consider using the Cassandra framework, as opposed to running Cassandra on Marathon.