mantl / mesos-consul

Mesos to Consul bridge for service discovery
Apache License 2.0
338 stars 95 forks source link

Non-routable IP Address w/ docker #29

Closed micahlmartin closed 8 years ago

micahlmartin commented 8 years ago

Perhaps my setup is wrong but I'm trying to figure out how to get the proper IP address registered in consul. When a new service is registered in Marathon it gets assigned a docker IP address:

   statuses:[  
      {  
         labels:[  
            {  
               key:"Docker.NetworkSettings.IPAddress",
               value:"172.17.0.14"
            }
         ],
         state:"TASK_RUNNING",
         timestamp:1444843301.64405
      }
   }

The problem is that the 172.17.0.14 gets registered in consul but I wont actually be able to access that IP from outside the host. What I need to be able to do is have it register the IP address of the HOST so that I can access it. How are you guys handling this? Is there a better of way setting this up or am have I missed the boat completely?

micahlmartin commented 8 years ago

Perhaps it should use the IP of the slave? It could look it up in the state.json also. That would solve my issue.

micahlmartin commented 8 years ago

I see it looks like it looks up all of the IP's available, but when it registers the service it just grabs the first one -> https://github.com/CiscoCloud/mesos-consul/blob/fc352bfbf15ac285c21d4f5afca779e65c3efb53/state/state.go#L91.

ChrisAubuchon commented 8 years ago

I think that I'm going to have to make the IP lookup order configurable. Maybe something like adding a command line option --mesos-resolve=docker,mesos,host with the default being netinfo,mesos,docker,host.

micahlmartin commented 8 years ago

yeah, I was thinking the same thing. Registrator uses the host IP by default and has the --internal flag specifically for using the docker containers internal IP.

ChrisAubuchon commented 8 years ago

I have made mesos-consul match the behavior of mesos-dns. The default IP search order is netinfo,mesos,host. That should work for you. Commit https://github.com/CiscoCloud/mesos-consul/commit/c652fca00f77e9f32d4c830c531dc1f5529d26b5 has this change. The v0.3 docker container has been updated.

micahlmartin commented 8 years ago

Awesome! Thanks so much for the quick turn around time.

marianodominguez commented 8 years ago

Hello !

not sure how's supposed to look for names : host is being ignored and external Ip is not in state.json:

"statuses": [ { "container_status": { "network_infos": [ { "ip_address": "172.17.0.4" } ] }, "labels": [ { "key": "Docker.NetworkSettings.IPAddress", "value": "172.17.0.4" } ], "state": "TASK_RUNNING", "timestamp": 1444952541.36739 } ]

host and mesos are ignored

"--mesos-ip-order=host,mesos,netinfo,docker"

ServiceName":"rxxx","ServiceTags":["nonprod"],"ServiceAddress":"172.17.0.2","ServicePort":31823}]

ChrisAubuchon commented 8 years ago

@marianodominguez Commit https://github.com/CiscoCloud/mesos-consul/commit/0791bff8901bd4dc81b8ab7a94957a7658a42640 should get host working correctly.

marianodominguez commented 8 years ago

Does indeed! Thanks for the fast fix.

On Thursday, October 15, 2015, ChrisAubuchon notifications@github.com wrote:

@marianodominguez https://github.com/marianodominguez Commit 0791bff https://github.com/CiscoCloud/mesos-consul/commit/0791bff8901bd4dc81b8ab7a94957a7658a42640 should get host working correctly.

— Reply to this email directly or view it on GitHub https://github.com/CiscoCloud/mesos-consul/issues/29#issuecomment-148577763 .


Mariano Domínguez Molina


cookandy commented 8 years ago

thank you for this fix!