Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes communication between microservices

We are developing an application microservices based. They will be deployed to kubernetes with Helm Package Manager and all of them stored their own repository and helm chart. Below are the names of our microservices.

My confusion is, before the deployment how can I specify that backend's pod needs to be communicate with UI's , API's and Auth's Pods.App can know to make a connection to UI/AUTH/whatever but what is the best way to manage this between microservices pods.

Architecture

  1. Backend
  2. UI
  3. API
  4. Auth
like image 242
semural Avatar asked Sep 05 '25 06:09

semural


1 Answers

The recommended way to manage the communication between microservices in Kubernetes is to use Services.

Basically, you need to wrap each of your microservices into a cluster IP service, then you are able to access its by the use of it's unique DNS record / Environment variables / by the use of a service mesh framework, like Linkerd

You can have one helm chart per microservice. That helmchart will contain yaml files for everything related to that microservice: deployments, config maps, secrets, etc., but also for the service (it's better to have a separate yaml file for it).

By the use of services, it's easy for the backend service to communicate with the rest of services, because the IP addresses of all the services will be injected in environment variables of the backend container, as you can see here

So you just have to update your backend app to read the IP of the microservice you want to connect to (from env variables) and then you are able to connect to it.

like image 124
Cosmin Ioniță Avatar answered Sep 07 '25 21:09

Cosmin Ioniță