Kubernetes multi servers communication

1/28/2019

I have a question regarding Kubernetes networking.

I know that in Docker swarm if I want to run difference containers on difference servers, I need to create an overlay network, and then all the containers (from all the servers) will be attached to this network and they can communicate with each other (for example, I can ping from container A to container B).

I guess that in Kubernetes there isn't an overlay network - but another solution. For example, I would like to create 2 linux containers on 2 servers (server 1: ubuntu, server 2: centos7), so how do the pods communicate with each other if there isn't an overlay network?

And another doubt - can I create a cluster which consists of windows and linux machines with kubernetes?I mean, a multi platform kubernetes which all the pods communicate with each other.

Thanks a lot!!

-- Johnykp
docker
kubernetes

1 Answer

1/28/2019

In kubernetes, pods communicate with each other through service. To access any pod within cluster, it must be exposed using clusterIP service. So if you created service before creating pods, you will have env variable for each available service within container. Using that you can ping or access services and in turn pods.

For example: Suppose you have two pods U1 and C1 and those are exposed by service named U-SVC and C-SVC respectively.

So if you want to access C1 from U1, you will have C-SVC service env variables(C-SVC_SERVICE_HOST,C-SVC_SERVICE_PORT) within container which you can use for access.

Also if DNS server set for your cluster, you can access service without env varibles.

-- Rajesh Deshpande
Source: StackOverflow