<p>I have a backend API &amp; Frontend application that i want to deploy on Kubernetes, all using docker images.
I know how to deploy the Frontend using a Loadbalancer service &amp; Ingress to expose the Frontend to the public internet.
The question i have is about how the backend API service will communicate with the frontend.</p>
<p>I want to deploy the backend API using ClusterIP service,
so it's only accessible to the Frontend from within the cluster,
instead of exposing the backend API using ingress, hence, and no public access to the backend API</p>
<p>Is this a good approach if i do decide to use Cluster IP?
&amp; how will the Frontend be able to access the backend?
will it be using <code>http://localhost:4000</code>? or if an IP is generated it'll be fixed and it won't change? What's the best way to have an URL for the backend which the frontend can call</p>

james
<p>There are various options on connecting your frontend to backend and it all depends on your application architecture.</p>
<p>You can expose your frontend using <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/" rel="nofollow noreferrer">Ingress</a>- it allows you to expose different parts of your app using different paths. And backend pods can be accessible only within cluster. You can check <a href="https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/" rel="nofollow noreferrer">&quot;Connecting Applications with Services
&quot;</a> in Kubernetes documentation.</p>
<p>There are few examples available online that might help you decide how to approach it.</p>
<ol>
<li><p>You can take a look in official documentation: <a href="https://kubernetes.io/docs/tasks/access-application-cluster/connecting-frontend-backend/" rel="nofollow noreferrer">Connect a Front End to a Back End Using a Service</a>.</p>
</li>
<li><p>There is a tutorial on <a href="https://medium.com/better-programming/kubernetes-deployment-connect-your-front-end-to-your-back-end-with-nginx-7e4e7cfef177" rel="nofollow noreferrer">how to connect frontend to backend using nginx</a></p>
</li>
<li><p>Similar question was also asked in SO, where <a href="https://stackoverflow.com/a/45171567/12237732">good answer was given</a>.</p>
</li>
</ol>
