It’s not possible now, but hopefully it will be in the future. Related mesos issue: https://issues.apache.org/jira/browse/MESOS-2044 <https://issues.apache.org/jira/browse/MESOS-2044>
> On 16 Jul 2015, at 22:57, Ondrej Smola <ondrej.sm...@gmail.com> wrote: > > I dont think there is way how can MesosDNS help you in this case ... when you > rely on "classic" DNS lookups - they are based on looking up DNS -> IP (a, > aaaa records) - there is no port lookup (they use port you provide). > > https://mesosphere.github.io/marathon/docs/service-discovery-load-balancing.html > > <https://mesosphere.github.io/marathon/docs/service-discovery-load-balancing.html> > > is a good starting point. > > > > > 2015-07-16 22:24 GMT+02:00 Dvorkin-Contractor, Eugene (CORP) > <eugene.dvorkin-contrac...@adp.com > <mailto:eugene.dvorkin-contrac...@adp.com>>: > Thanks. I was hoping that mesos-dns will do it for me and I can run services > on different ports even on the same node. I was hesitant to use HAProxy. > I think I have to use HAProxy/Bamboo to achieve this functionality. > > From: Ondrej Smola <ondrej.sm...@gmail.com <mailto:ondrej.sm...@gmail.com>> > Reply-To: "user@mesos.apache.org <mailto:user@mesos.apache.org>" > <user@mesos.apache.org <mailto:user@mesos.apache.org>> > Date: Thursday, July 16, 2015 at 2:55 PM > To: "user@mesos.apache.org <mailto:user@mesos.apache.org>" > <user@mesos.apache.org <mailto:user@mesos.apache.org>> > Subject: Re: Mesos-DNS configuration problem with dockerized web application > > Hi, > > "portMappings": [ > { "containerPort": 8080, "hostPort": 80, "servicePort": 9000, > "protocol": "tcp" } > ] > > will work - you need to specify required port as hostPort > only limitation of this setup is that you wont be able to run multiple > services on single host with same hostPort (port collision) > but for most setups you should be ok with just choosing random/different > ports for different services or ensuring there are more nodes than requested > instances with same port > if you want to use random port - you will need some have logic to query DNS > and parse SRV records and for example setup HA proxy with correctly assigned > ports > > this problem can also be solved using SDN (for example flannel/weave -) > assigning each service unique IP address and dont care about port collisions > - but this is not related to MesosDNS - just info :) > > > > > 2015-07-16 17:58 GMT+02:00 Dvorkin-Contractor, Eugene (CORP) > <eugene.dvorkin-contrac...@adp.com > <mailto:eugene.dvorkin-contrac...@adp.com>>: > Hi, > I can’t access my application using mesos-dns. Neither port 8123 nor 8080 > responding. I think I miss something in configuration but can’t find problem > myself. > > I have a very basic java application that listen on port 8080. I have created > docker image and deployed this application to marathon. > My deployment configuration is following: > $ cat app-slick.json > { > "container": { > "type": "DOCKER", > "docker": { > "image": "edvorkin/slick-swagger:1", > "network": "BRIDGE", > "portMappings": [ > { "containerPort": 8080, "hostPort": 0, "servicePort": 9000, > "protocol": "tcp" } > ] > } > }, > "cmd": "java -jar /tmp/spray-slick-swagger-assembly-0.0.2.jar Boot", > "id": "slick-swagger-demo", > "instances": 1, > "cpus": 0.1, > "mem": 256, > "constraints": [ > ["hostname", "UNIQUE"] > ] > } > Application successfully deployed to 2 nodes and assigned random port of > 31990 and 31000 on each node. > Now I installed and configured Mesos-DNS with config.json > { > "zk": "zk://172.31.50.58:2181 <http://172.31.50.58:2181/>,172.31.50.59:2181 > <http://172.31.50.59:2181/>,172.31.50.60:2181/mesos > <http://172.31.50.60:2181/mesos>", > "refreshSeconds": 60, > "ttl": 60, > "domain": "mesos", > "port": 53, > "resolvers": ["172.31.0.2"], > "timeout": 5, > "email": "root.mesos-dns.mesos" > } > > > and I got following: > > $ dig slick-swagger-demo.marathon.mesos > > ; <<>> DiG 9.9.4-RedHat-9.9.4-18.el7_1.1 <<>> > slick-swagger-demo.marathon.mesos > ;; global options: +cmd > ;; Got answer: > ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20376 > ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0 > > ;; QUESTION SECTION: > ;slick-swagger-demo.marathon.mesos. IN A > > ;; ANSWER SECTION: > slick-swagger-demo.marathon.mesos. 60 IN A 172.31.11.202 > slick-swagger-demo.marathon.mesos. 60 IN A 172.31.11.203 > > ;; Query time: 1 msec > ;; SERVER: 54.86.164.193#53(54.86.164.193) > ;; WHEN: Thu Jul 16 15:23:04 UTC 2015 > ;; MSG SIZE rcvd: 83 > > > curl > http://localhost:8123/v1/services/_slick-swagger-demo._tcp.marathon.mesos > <http://localhost:8123/v1/services/_slick-swagger-demo._tcp.marathon.mesos> > |python -m json.tool > % Total % Received % Xferd Average Speed Time Time Time > Current > Dload Upload Total Spent Left Speed > 100 289 100 289 0 0 1916 0 --:--:-- --:--:-- --:--:-- 1926 > [ > { > "host": "slick-swagger-demo-15491-s42.marathon.mesos.", > "ip": "172.31.11.203", > "port": "31990", > "service": "_slick-swagger-demo._tcp.marathon.mesos" > }, > { > "host": "slick-swagger-demo-20495-s43.marathon.mesos.", > "ip": "172.31.11.202", > "port": "31000", > "service": "_slick-swagger-demo._tcp.marathon.mesos" > } > ] > > But when I try to access my application using dns name, I can’t get get > response. > curl http://slick-swagger-demo.marathon.mesos:8080 > <http://slick-swagger-demo.marathon.mesos:8080/> > curl: (7) Failed connect to slick-swagger-demo.marathon.mesos:8080; > Connection refused > > curl slick-swagger-demo.marathon.mesos:8123 > 404: Page Not Found > > curl slick-swagger-demo.marathon.mesos:31990 – produce desired results, but > that binded to a random port. > > How do I configure mapping between random ports and my service? > I would like to be able to access my server on port 80 for example > Curl http://slick-swagger-demo.marathon.mesos > <http://slick-swagger-demo.marathon.mesos/> > > Thanks > Eugene > > > > > > This message and any attachments are intended only for the use of the > addressee and may contain information that is privileged and confidential. If > the reader of the message is not the intended recipient or an authorized > representative of the intended recipient, you are hereby notified that any > dissemination of this communication is strictly prohibited. If you have > received this communication in error, notify the sender immediately by return > email and delete the message and any attachments from your system. > >