How to resolve host name of kubernetes pod while creating grpc client from other pod? How to resolve host name of kubernetes pod while creating grpc client from other pod? kubernetes kubernetes

How to resolve host name of kubernetes pod while creating grpc client from other pod?


Addressing your pod directly is not a good solution since Kubernetes may need to move your pods around the cluster. This can occur for example because of the failing node.

To allow you clients/traffic to easy find desired containers you can place them behind a service with single static IP address. Service IP can be look up through DNS.

This is how you can connect to the service through it`s FQDN:

my-service.default.svc.cluster.local 

Where my-service is your service name, default for your namespace and svc.cluster.local is a configurable cluster domain suffix used in all cluster services.

It's worth to know that you can skip svc.cluster.local suffix and even the namespace if the pods are in the same namespace. So you'll just refer to the service as my-service.

For more you can check K8s documents about DNS.