<p>I have 3 kubernetes services which are:</p>

<pre><code>service 1:

name: abc

service 2:

name: def

service 3:

name: hgk
</code></pre>

<p>In application running on service 1, I successfully use environment variables to get cluster IP of other services. </p>

<pre><code>System.getenv(DEF_SERVICE_HOST); --&gt; success
System.getenv(HGK_SERVICE_HOST); --&gt; success
</code></pre>

<p>However, when I call the service 1 's environemnet, it return null</p>

<pre><code>System.get(ABC_SERVICE_HOST); ---&gt; null 
</code></pre>

<p>Looks like it can not get its own cluster IP. </p>

<p>Do you guys have any ideas?
Thank you very much!</p>

<p>The only service environment variables that are populated in a pod are the services that existed before the pod created. Environment variables are not injected into running pods once they've already been started.</p>

<p>I'm guessing that you created the <code>abc</code> replication controller / pods before you created the <code>abc</code> service. If you kill the existing pods and let them be recreated, they should have the ABC_SERVICE_HOST environment variable set.</p>
