How to Inject External IP of service to a Pod?

2/25/2019

I have created a Kubernetes Service of type LoadBalancer on EKS. After service is created it will get an external IP/DNS name. I want to create a pod (through Deployment/Stafulset workload). Is there any way to provide External IP information to the POD ?

-- Karthik
amazon-eks
kubernetes

1 Answer

2/25/2019

Maybe it is better to use something like STUN , read more on STUN here

As per wikipedia

Session Traversal Utilities for NAT (STUN) is a standardized set of methods, including a network protocol, for traversal of network address translator (NAT) gateways in applications of real-time voice, video, messaging, and other interactive communications.

It can be used by your application to identify it public IP address , it is mainly used in WebRTC , but maybe it might fit your use case as well

It provides a tool for hosts to discover the presence of a network address translator, and to discover the mapped, usually public, Internet Protocol (IP) address and port number that the NAT has allocated for the application's User Datagram Protocol (UDP) flows to remote hosts. The protocol requires assistance from a third-party network server (STUN server) located on the opposing (public) side of the NAT, usually the public Internet.

As mentioned above , you will need to use a STUN server in order to find your public external IP address. A good list can be found here

-- fatcook
Source: StackOverflow