<p>I have multiple instance of containers deployed in kubernetes.</p>

<p>The application in the container requires the public IP from the pod / node.  </p>

<p>From the deployment manifest, I tried to use the following, </p>

<ul>
<li>status.podIP</li>
<li>spec.nodeName</li>
</ul>

<p>But both of them return the private IP address of my node rather then the public IP.  </p>

<p>Can someone help explain where the status.podIP value comes from?  Is it coming from the node manifest?  Or from the VM / docker configuration?
Any suggestion on how I can get the public IP address into my container?</p>

<p>Thanks</p>

<p>Public IP may not be available through Kubernetes. But you can use external services to query the IP.</p>

<pre><code>$ curl ipinfo.io/ip
</code></pre>

<p>Is one possible way. But they have rate limiting. You might find other options also. Next option is to set a Nginx server on a know machine with below config</p>

<pre><code>location = /ip {
    add_header Last-Modified $date_gmt;
    add_header Cache-Control 'private no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
    if_modified_since off;
    expires off;
    etag off;

    default_type text/plain;
    return 200 "$remote_addr";
}
</code></pre>

<p>And then call this endpoint using the public IP of the nginx hosting this</p>

<pre><code>$ curl &lt;publicipofnginx&gt;/ip
</code></pre>

<p>This will give the public of the machine making the curl call. </p>
