<p>I have two application frontend developed using angular and backend developed using spring-boot. Both the app are running in same namespace.</p>
<p>Already created two service of type: Loadbalancer.</p>
<ol>
<li>frontend say <code>frontend-app-lb</code> (exposed 9001)</li>
<li>backend say <code>backend-app-lb</code> (exposed 9000).</li>
</ol>
<p>I am able to get the response with the External Ip. using curl <code>http://&lt;External-ip&gt;:900[0/1]/</code></p>
<p>In angular app, i configured environment-prod.ts, with baseurl as <code>http://&lt;External-ip-of-backend-app-lb&gt;:9000/</code>. With the CORS allowed, able to access the backend app.</p>
<p>I also know that, if the app is running in different namespace, we can access the application/pod from different namespace, using this <code>http://&lt;service-name&gt;.&lt;namespace&gt;.svc.cluster.local:port</code>.</p>
<p>How to access the backend app running in the same namespace just using the service name in baseurl like <code>http://backend-app-lb:9000</code>. - Is this possible?</p>

<p>i found out, accessing <code>http://backend-app-lb:9000</code> might not be a approach to do it.</p>
<p>Other approaches:</p>
<p>Approach #1: Using Azure application gateway:</p>
<ul>
<li><p>Expose the backend service a LoadBalancer type service, (in my case the applications deployed in AKS). So a Application Gateway (Layer 7) was configured.</p>
<ul>
<li>say any url <code>/backend-api</code> connect to the backend application.</li>
</ul>
</li>
<li><p>In frontend application <code>environment.prod.ts</code>, use the <code>/backend-api</code> as baseurl to connect to the backend api.</p>
</li>
</ul>
<p>Approach #2: Using Nginx proxy</p>
<ul>
<li>If the frontend application is developed on Ngnix server, using the configuration the we create a proxy and access the backend service.</li>
<li>Reference available at <a href="https://kubernetes.io/docs/tasks/access-application-cluster/connecting-frontend-backend/" rel="nofollow noreferrer">Kubernetes documentation</a></li>
<li>In this case the backend application can be exposed as service (it can be of type NodePort or LoadBalancer).</li>
</ul>
<p>Both approach, in a way makes the Frontend application access to the backend service simple and no need for manipulation during build.</p>
