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 [0] https://kubernetes.io/docs/tasks/configure-pod-container/environment-variable-expose-pod-information/ On Fri, Mar 3, 2017 at 6:30 PM <[email protected]> wrote: > 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. > > > On Tuesday, March 3, 2015 at 7:05:36 PM UTC-6, Brian Grant wrote: > > 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: > > > https://groups.google.com/forum/#!searchin/google-containers/kafka/google-containers/7e1x1r92SV0/vhbk2lOrxSkJ > > > > On Thursday, February 19, 2015 at 3:54:22 AM UTC-8, Stefan Jacobs wrote: > > 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 > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/kubernetes-users. > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/kubernetes-users. For more options, visit https://groups.google.com/d/optout.
