Passing external Node/Minion IP to Pod

1,014 views
Skip to first unread message

Stefan Jacobs

unread,
Feb 19, 2015, 6:54:22 AM2/19/15
to google-c...@googlegroups.com
Hi there, 

Is there a way to pass the external node IP to a pod? 

I have a kafka docker container that needs the host IP (advertised host i.e. IP of node the pod is being deployed on).

For instance, kubectl get pods returns:

POD                      IP                  CONTAINER(S)        IMAGE(S)                 HOST                LABELS              STATUS

zookeeper           10.244.36.4         zookeeper           zookeeper:latest   192.168.0.104/      name=zookeeper      Running

I want a way of accessing that host IP (192.168.0.104) at pod startup. 

It would be nice to have a kubernetes evironment variable that simply pass the IP of the host the pod is being deployed on. Like services are currently doing with pod IPs. 

Thanks, 

Stefan

Brian Grant

unread,
Mar 3, 2015, 8:05:36 PM3/3/15
to google-c...@googlegroups.com
Do you want the host IP or the pod IP? If the former, why? Most containers shouldn't need to know what hosts they are on. If the latter, can't you get that from linux?

You could also create one service per instance and pass the service DNS names to whatever needs to know them. Eventually we plan to provide better support for that pattern (see #260).

If you need multiple ports on the same IP address, that change is in flight, but there is a hack that makes it possible for services, described in another recent thread about kafka/zookeeper:

ssm...@h5g.com

unread,
Mar 3, 2017, 1:30:03 PM3/3/17
to Kubernetes user discussion and Q&A, google-c...@googlegroups.com
Brian, I am in a situation where I have a series of pods that all need to have their own EIP. The application running in the pod register's itself with a custom router giving statistics and metadata (including it's external ip). Clients make requests to the custom router and get back the EIP of the 'best' pod to connect to. We are matching up 1 service to 1 deployment to allow the pod to have it's own EIP.

We are moving to kubernetes and would like to keep this process the same. Therefore, if the pod can find it's own EIP through an environment variable or hosts file or even a file written to the file system then we can continue with our current implementation.

I know this isn't exactly the same request as the OP but was curious if there's any suggestions that can be made.

Matthias Rampke

unread,
Mar 3, 2017, 2:16:21 PM3/3/17
to kubernet...@googlegroups.com
You can find out everything there is to know about the node from the Kubernetes API. A simple way to access that may be to include the kubectl binary in the container, rely on the auth token it gets from the default ServiceAccount, and script the registration around that.

The use the Downward API[0] to let the pod know the pod name and namespace via environment variables, and find the node name from there. Then fetch the node details.

/MR



--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.

Scott...@high5games.com

unread,
Mar 3, 2017, 3:05:16 PM3/3/17
to kubernet...@googlegroups.com

Thanks Matthias,  That’s pretty much where I landed too.  I already have a utility that will query the api so I can just add the functionality there.  The other option was to send the hostname or service to the router and let the router look up the external ip based off the service name.  Either way ends up at the same conclusion.  We have to query the service for the information.  The last hurdle is making sure we wait to register until the service has an EIP allocated and registered.

 

Thanks!

--
You received this message because you are subscribed to a topic in the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kubernetes-users/m_48qvTg9r0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kubernetes-use...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages