Very simple question, I have a front-end app running in kubernetes. I would like to create a back-end containerized app that would also be in kubernetes obviously.
User actions in the frontend would need to trigger the execution of a command on the backend (echo success! for example). The UI also needs to know what was the command's output.
What is the best way to implement this in k8s? Either through an internal service, or the two apps can also be in the same pods.
Perhaps there is some kind of messaging involved with applications such as rabbitMQ?
CodePudding user response:
That is depends on your application how you are planning.
People host frontend on bucket also and from there send HTTP request to backend or so.
You can keep front and backend in different PODs also or in single also.
For example, if you are using the Node JS with express you can run as simple API service POD also and keep frontend with it also to serve.
You can use the K8s serivce name for internal communication, instead of adding the Message broker(RabbitMQ, Redis also can be used) unless your web app really need it.
i would also recommend checking out the : https://learnk8s.io/deploying-nodejs-kubernetes
Github repo of application : https://github.com/learnk8s/knote-js/tree/master/01
Official example : https://kubernetes.io/docs/tutorials/stateless-application/guestbook/
