<p>I have two k8s pods running. Each pod has a single container inside each of them. My app will be running inside each container. I want to make a direct HTTP call from my app in Pod1 to my app in Pod2.</p>

<p>Assume that I have some sort of persistent storage held outside the clusters. So my logic is looking something like this. </p>

<pre><code>App in Pod1 -&gt; get Pod1 IP address -&gt; save to external storage

App in Pod2 -&gt; read Pod1 IP address from storage -&gt; complete HTTP call to App1 in Pod1
</code></pre>

<p>How can I get this IP address from within my application. I am using Java (Play Framework).</p>

john
<p>You can expose Pod IP (or any other attribute of the Pod descriptor) to the Pod's environment variables by putting to your Pod manifest something like this:</p>

<pre><code>env:
- name: MY_POD_IP
  valueFrom:
    fieldRef:
      fieldPath: status.podIP
</code></pre>

<p>That being said, the answer by Yonah is likely what you need really. Service discovery is a first class citizen in Kubernetes.</p>
