I want to create a web application using Angular and microservices backend serving some REST api. Then I would like to deploy everything on Kubernetes.
Lets say application will serve some drinks (Coffea and Tea). For the simplification lets assume that app is fully stateless and I want to 2 have microservices.
Without Kubernetes I would do this in such a way:
Coffea service - rest API for /api/coffea endpoint
Tea service - rest API for /api/tea endpoint
Nginx - static contents with Angular app (HTML/CSS/JS/images etc.) and the gateway (proxy for /api/coffea and /api/tea endpoints)
Now the question is how to reflect this in Kubernetes? Would it be enough just to deploy everything in a several replicas, then expose Coffea and Tea services as a NodePort and finally expose Nginx as a LoadBalancer? Is this a right approach? Should I use Ingress instead of making my own nginx proxy? If yes, then how to serve static contents using Ingress Controller?
Thanks in advance!
Would it be enough just to deploy everything in a several replicas, then expose Coffea and Tea services as a NodePort and finally expose Nginx as a LoadBalancer?
Probably yes, it would be sufficient to make your application work, but the best way is to use your services with cluster IP and expose it by Ingress. Because Ingress is good for routing but it is not good for serving static content, so you can use the Nginx as a web server only for static content. Your app will look like 3 services hidden behind the Ingress:
Here is a good answer why it is better to use Nginx as a service for static content.