I need to design a website solution with multiple spa pages. What I thought as a high-level design is as below:-
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.
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.
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.
My questions now are below:-
Is there any best practice or other design solution for above?
You can use PodAffinity
to co-locate your pods.
How will I achieve path based routing like www.abc.com/foo should call my web page pod?
You can use a Kubernetes Ingress
. 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.
How can I expose the pod to external world i.e. internet without using a load balancer?
You can use a NodePort
type of Service
. 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.
Should I have different repos for each pod?
git repos? sure, you will have to have different container images for each application.