Reputation: 233
I use RPC protocol app as a micro-service and an API Gateway in front of them as a proxy.
Now I want to use k8s to deploy micro-service, the API gateway is out of k8s cluster, RPC micro-service is deployed by k8s, there are three replicas RPC micro-service in my cluster.
My question is how could I directly access k8s's pod, because I must build a connection pool to hold these connections, for example, I have three RPC micro-service pod.
this is my architecture architecture image
Upvotes: 0
Views: 1170
Reputation: 26034
You shouldn't consume your RPC micro-service from a pod directly but through a Kubernetes service.
First, you have to expose your RPC as a public K8S service, that will provide you a port where it is listening. With the IP of the cluster (can be more than one, of course) and that port, you will be able to consume your RPC micro-service.
Check the docs to learn how to expose it:
https://kubernetes.io/docs/concepts/services-networking/service/
You can access a pod directly using hostNetwork
configuration parameter. However, Kubernetes doesn't recommend it: https://kubernetes.io/docs/concepts/configuration/overview/
If you need to keep a shared session or something like that between your replicas, I would use another external component like Redis or something like that.
Upvotes: 1