Re: How to get the IP addresses of the instances of the same application


Jason Sherron
 

I'm also very interested to hear about what you might need to do with
direct container-to-container communication. We've started an effort to
enable it at the network layer, and as Dan gets at, service discovery is a
thorny area, and we'd like to hear your feedback.

On Fri, Mar 4, 2016 at 9:07 AM, Daniel Mikusa <dmikusa(a)pivotal.io> wrote:

On Thu, Mar 3, 2016 at 10:32 PM, Malmee Weerasinghe <malmee(a)wso2.com>
wrote:

Hi,
When I push an application to cloud foundry, "cf scale myApp -i 5" will
increase the number of instances of my application to 5. I want to get the
ip addresses of these instances. Is there any way to get the ip addresses
and ports of the 5 instances of my application? Is there any API?
Look at the environment variables in the container, things starting with
VCAP_ or CF_ provide you with details about the container, app and bound
services. It sounds like you're looking for CF_INSTANCE_ADDR in particular.

That said, what are you planning to do with this information? You don't
really want to try and talk directly to specific app instances. Those
instance can come and go and the IP's can change. If you're talking
directly then you have the tedious task of tracking all that information.
If instead you talk through the URL mapped to your app then you never have
to worry about things changing.

It's probably also worth mentioning that some CF installations will
prohibit direct container to container communication.

Dan


I am running cloud foundry with diego in bosh-lite. In documents I have
seen that garden API gives container information, but how to call the
garden API? I highly appreciate your responses regarding this issue.

Thank you.

Join cf-dev@lists.cloudfoundry.org to automatically receive all group messages.