<p>I have a Kubernetes <code>Service</code> with a static <code>External IP</code> assigned to a <code>Replication Controller</code> managing 1 application distributed to 2 <code>Pods</code>. I can access the application using the external IP, this part works fine.</p>

<p>I'd like now to have the application inside the Pods using the same IP when making HTTP requests to external applications (outside the cluster).</p>

<p>A simple call to <code>https://api.ipify.org/</code> shows that the IP of this application is completely different from the external IP it answers at. How can I make it use the same IP?</p>

<p>Theshort and simple answer is - you can't. Your pods are assigned IPs that are internal to your cluster, most likely from a per node range of particular cluster wide network address space. When talking to external world, pods traffic originates on an internally bridged interface/IP and if the destination is not part of the cluster it leaves by means of particular <em>node</em> default route, ending in being SNATed to the node IP, or to the IP of the NAT gateway if your traffic goes through such.</p>

<p>Even if you were to create custom SNAT rules for pods by means of some k8s watching etc. (much like ingress controller), the traffic would still bounce off of loadbalancer rather then reach your pods.</p>

<p>If you need a maintained IP address, what you can do, is pass your pods traffic via NAT gateway and make sure it NATs as you expect (this would not give you the same IP as your service, just a "stable" one), or make traffic like http requests go via PROXY with a stable IP(s).</p>

<p>All in all, while to some extent possible, it's unlikely to be worth the headache of setting it up.</p>
