Pod to Pod communication for a NodePort type service in kubernetes

3/6/2019

I have a statfulset application which has a server running on port 1000 and has 3 replicas. Now, I want to expose the application so I have used type: NodePort. But, I also want 2 replicas to communicate with each other at the same port. When I do nslookup in case of NodePort type application it gives only one dns name <svc_name>.<namespace>.svc.cluster.local (individual pods don't get a dns) and the application is exposed.

When I do clusterIP: None I get node specific DNS <statfulset>.<svc_name>.<namespace>.svc.cluster.local but application is not exposed. But both do not work together. How can I achieve both, expose the same port for inter replica communication and expose same port externally?

-- 250
docker
kubernetes

1 Answer

3/6/2019

LoadBalancer: Exposes the service externally using a cloud provider’s load balancer. NodePort and ClusterIP services, to which the external load balancer will route, are automatically created.

-- Vikas Kumar
Source: StackOverflow