<p>I need to design a website solution with multiple spa pages.
What I thought as a high-level design is as below:-</p>

<p>There will be one machine for each spa page which will just render the UI, do SSR and take request from the browser.
For example, www.abc.com/foo will be routed to this machine. I'm thinking of to put the application UI code in kubernetes pod and host that on the machine/node. Also using KOPS I will manage the autoscaling of nodes and pods. </p>

<p>Now, this application in the pod will call other pods for data to be shown on the web page. For example, www.abc.com/API/foo will be called from pod1. I'm thinking to make this another pod which will live on the same node as the web page pod node. </p>

<p>So now I have 2 pods living on a single node which will autoscale as per traffic.
Similarly, for each page I have on my website I will have a node with 2 pods each.</p>

<p>My questions now are below:-</p>

<ol>
<li>Is there any best practice or other design solution for above?</li>
<li>How will I achieve path based routing like www.abc.com/foo should call my web page pod?</li>
<li>How can I expose the pod to external world i.e. internet without using a load balancer?</li>
<li>Should I have different repos for each pod?</li>
</ol>

<blockquote>
  <p>Is there any best practice or other design solution for above?</p>
</blockquote>

<p>You can use <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/" rel="nofollow noreferrer"><code>PodAffinity</code></a> to co-locate your pods.</p>

<blockquote>
  <p>How will I achieve path based routing like www.abc.com/foo should call
  my web page pod?</p>
</blockquote>

<p>You can use a Kubernetes <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/" rel="nofollow noreferrer"><code>Ingress</code></a>. Since this is a layer 7 facility you will able to do multiple host paths, keep in mind that this is generally exposed to the outside using a LoadBalancer type of service.</p>

<blockquote>
  <p>How can I expose the pod to external world i.e. internet without using
  a load balancer?</p>
</blockquote>

<p>You can use a <a href="https://kubernetes.io/docs/concepts/services-networking/service/#nodeport" rel="nofollow noreferrer"><code>NodePort</code></a> type of <code>Service</code>. Note that you generally use either an Ingress or a NodePort service, the downside for this approach is that you won't be able to do paths and that will have to be handled in your application.</p>

<blockquote>
  <p>Should I have different repos for each pod?</p>
</blockquote>

<p>git repos? sure, you will have to have different container images for each application.</p>
