Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How does port pairing work? #48

Open
tnolet opened this issue Jul 31, 2014 · 1 comment
Open

Question: How does port pairing work? #48

tnolet opened this issue Jul 31, 2014 · 1 comment

Comments

@tnolet
Copy link

tnolet commented Jul 31, 2014

Was looking around how to map multiple exposed ports to marathon/mesos ports using deimos. I was surprised by the following:

Starting a container that exposes ports 8080 and 8081, I (naively) assigned two ports in my json file:

{
    "container": {
    "image": "docker:///tnolet/hello:1.0",
    "options" : ["-P"]
  },
  "id": "hello2",
  "instances": "1",
  "cpus": ".5",
  "mem": "512",
  "uris": [],
  "cmd": "",
  "ports" : [40195,40196]
}

However, this resulted in deimos picking and auto incrementing two ports, 31267 and 31268:

Jul 31 17:17:17 ec2-54-84-57-179 deimos[5707]: deimos.docker.run() Port pairings (Mesos, Docker) // [(31627, 8080), (31628, 8081)]
Jul 31 17:17:17 ec2-54-84-57-179 deimos[5707]: deimos.containerizer.docker.launch() call // docker run --sig-proxy --rm --cidfile /tmp/deimos/mesos/54f421fd-0935-4f34-8be9-33a17862024e/cid -w /tmp/mesos-sandbox -v /tmp/deimos/mesos/54f421fd-0935-4f34-8be9-33a17862024e/fs:/tmp/mesos-sandbox -P -p 31627:8080 -p 31628:8081 -c 512 -m 512m -e PORT=31627 -e PORT0=31627 -e PORTS=31627,31628 -e PORT1=31628 tnolet/hello:1.0

If I leave the "port" key out of my json file, deimos only maps the lowest numbered port.
I love the auto incremented ports, but I'm not sure how this is triggered.

@solidsnack
Copy link
Contributor

These auto-incremented ports are actually provided by Mesos, at Marathon's request. Deimos just maps the ports it sees in the TaskInfo -- it doesn't have any port management logic. That is why the port pairings are listed as (Mesos, Docker).

Jul 31 17:17:17 ec2-54-84-57-179 deimos[5707]: deimos.docker.run() Port pairings (Mesos, Docker) // [(31627, 8080), (31628, 8081)]

The idea is to access the endpoints resource on Marathon and then construct a proxy configuration (using HAProxy, for example) to map between the ports allocated for the container and the "service ports" requested in the Marathon task JSON.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants