<p><strong>The context</strong></p>
<p>Let me know if I've gone down a rabbit hole here.</p>
<p>I have a simple web app with a frontend and backend component, deployed using Docker/Helm inside a Kubernetes cluster. The frontend is servable via nginx, and the backend component will be running a NodeJS microservice.</p>
<p>I had been thinking to have both run on the same pod inside Docker, but ran into some problems getting both nginx and Node to run in the background. I could try having a startup script that runs both, but <a href="https://runnable.com/docker/rails/run-multiple-processes-in-a-container" rel="nofollow noreferrer">the Internet</a> says it's a best practice to have different containers each be responsible for only running one service - so one container to run nginx and another to run the microservice.</p>
<p><strong>The problem</strong></p>
<p>That's fine, but then say the nginx server's HTML pages need to know what to send a POST request to in the backend - how can the HTML pages know what IP to hit for the backend's Docker container? Articles like <a href="https://levelup.gitconnected.com/how-to-access-a-docker-container-from-another-container-656398c93576" rel="nofollow noreferrer">this one</a> come up talking about manually creating a Docker network for the two containers to speak to one another, but how can I configure this with Helm so that the frontend container knows how to hit the backend container each time a new container is deployed, without having to manually configure any network service each time? I want the deployments to be automated.</p>

<p>You mention that your frontend is based on Nginx.</p>
<p>Accordingly,Frontend must hit the <strong>public</strong> URL of backend.</p>
<p>Thus, backend must be exposed by choosing the service type, whether:</p>
<ul>
<li><strong>NodePort</strong> -&gt; Frontend will communicate to backend with <code>http://&lt;any-node-ip&gt;:&lt;node-port&gt;</code></li>
<li>or <strong>LoadBalancer</strong> -&gt; Frontend will communicate to backend with the <code>http://loadbalancer-external-IP:service-port</code> of the service.</li>
<li>or, keep it <strong>ClusterIP</strong>, but add <strong>Ingress</strong> resource on top of it -&gt; Frontend will communicate to backend with its ingress host <code>http://ingress.host.com</code>.</li>
</ul>
<p>We recommended the last way, but it requires to have ingress controller.</p>
<p>Once you tested one of them and it works, then, you can extend your helm chart to update the service and add the ingress resource if needed</p>
