<p>I’ve two <strong>differen</strong>t apps in k8s that need needs to read data,e.g. <code>AppA</code> from <code>AppB</code>, both are deployed on the <strong>same cluster</strong></p>

<p>The <code>tricky</code> part here is that I need the both apps will deployed to any cluster and know the host and port to connect, I <strong>don't</strong> want to use hard-coded values.</p>

<p>e.g. </p>

<p>App A reads data from App B</p>

<p>App <code>B</code> is web application with rest API
hence app <code>A</code> needs to call like <a href="http://10.26.131.136:9090/api/app/getconfig" rel="nofollow noreferrer">http://10.26.131.136:9090/api/app/getconfig</a></p>

<p>App A know the service path: like <code>api/app/getconfig</code> of App <code>B</code> but how it can know the the <strong>host and the port</strong> of appB?</p>

<p>I cannot use it hardcoded , this works if I use <code>type:LoadBalacer</code> but this is hard-coded host and port, I need somehow to determine it on run-time maybe with serviceName, etc?</p>

NSS
<p>Note: The Kube-DNS naming convention is <code>service.namespace.svc.cluster-domain.tld</code> and the default cluster domain is <code>cluster.local</code></p>

<p>So you can refer to your app as ..svc as long as the services are in the same cluster. You then need to check the ports on which the apps are listening by issuing: </p>

<pre><code>kubectl -n &lt;namespace&gt; get svc
</code></pre>

<p>note the service identifier and issue: </p>

<pre><code>kubectl -n &lt;namespace&gt; get svc &lt;identifier&gt; -o yaml
</code></pre>

<p>This will list you the service manifest where you can see which port the app is listening on. </p>
