<p>I am trying to create a Kubernetes application in which, I have created one pod and service for backend(spring boot microservice) &amp; frontend pod and 
a loadbalancer service.</p>

<p>I wanted to know how would I call the backend API from frontend pod in Kubernetes?</p>

<p>Here are the running services:</p>

<pre><code>NAME         TYPE           CLUSTER-IP      EXTERNAL-IP       PORT(S)          AGE       SELECTOR
angular      LoadBalancer   10.100.15.215   a17f17fd2e25011e886100a0e002191e-1613530232.us-east-1.elb.amazonaws.com   4200:30126/TCP   12s       app=angular
kubernetes   ClusterIP      10.100.0.1      &lt;none&gt;                                                                    443/TCP          35m       &lt;none&gt;
login        ClusterIP      10.100.99.52    &lt;none&gt;                                                                    5555/TCP         13m       app=login,tier=backend
</code></pre>

<p>I am calling the following API from frontend and it is showing name not resolved error:</p>

<pre><code>http://login/login
</code></pre>

<p>I have also tried to call the  API with cluster IP but that failed.</p>

aac
<p>Looks like your backend service is running on port <code>5555</code>, so you would have to call your backend service like this:</p>

<pre><code>http://login:5555/login
</code></pre>

<p>This assuming the pods for your frontend are on the same Kubernetes <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/" rel="nofollow noreferrer">namespace</a>. If they are on a different namespace you would call something like this:</p>

<pre><code>http://login.&lt;namespace&gt;.svc.cluster.local:5555/login
</code></pre>

<p>Also as described <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/#namespaces-and-dns" rel="nofollow noreferrer">here</a>.</p>

<p>Note that this will work only within the cluster, if you are hitting your Angular frontend from a web browser outside of the cluster, this will not work, because the web browser would have no idea of where your backend is in the cluster. So either you will have to expose your backend using another LoadBalancer type of service or you may consider using a <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/" rel="nofollow noreferrer">Kubernetes Ingress</a> with an ingress controller.</p>
