I'm quite new to Kubernetes: my question may be more a question of design than of code. I was wondering: how Kubernetes can handle communication between one pod and replicas of another pods? My case is simple I have an API pod which pass parameters provided by an UI to a compute unit pods. I will have many replicas of the CU pods depending of my needs, they're waiting for the API to pass them a parameter to work with. Each CU pod has to work with a different parameter: they're all working the same way but not with the same parameter. How can I make my API pod aware of the CU pods available to send them the parameter so they can work. Is it automatic? Is it at least possible or is my cluster poorely designed?
I thought of another way to do this: as soon as my api get a parameter from the ui it will deploy a CU pod with, for example, the parameter given as an environment variable and the CU can work with it.
Thank you in advance for your help!
Suppose You have 5 CU pods running and ClusterIP service for them. Now when you send request to that service, load balancing will happen internally and service will forward request to a pod which is having less load. This is to maintain high availability of your backend pods. So in your case even if some of CU pods are down, you will not get affected
You need more number of pods than expected requests. Also use Autoscale to dynamically increase pods
In k8s, communication between pods is handled by services. To access any pod within cluster, you need to create ClusterIp service.
So in your case, you need to create ClusterIp service for CU pods so that they can be accessible. once you send request to this service from API pods, it will be sent to any CU pods(Auto load balancing will happen here) which you can not predict or control.
Also to send request from api pods, will get CU ClusterIp service name,port,host details available within API pod as env variable(provided you have created CU service before creating API pods). You can also setup DNS server to access service by their name from pods.