Pod Communication

12/2/2015

How does the communication between two different pods happen in Kubernetes?

In my case I have two pods: frontend and backend, both have different containers. I want my frontend pod to communicate with the backend pod but I don't want to use backend pod's IP( i.e. hard coded).

Is it possible through services?

-- Madhurima Mishra
kubernetes

2 Answers

12/2/2015

Is it possible through services?

Yes, services are the recommended way to handle this. Once you have your services set up for each pod (or replication controller, as is recommended), you can find the service IP via the service environment variable, e.g. BACKEND_SERVICE_HOST and BACKEND_SERVICE_PORT for a "backend" service.

-- Tim Allclair
Source: StackOverflow

5/31/2016

A recommended method is with the DNS cluster add-on: http://kubernetes.io/docs/user-guide/services/#dns


Example from the 'guestbook' app:

https://github.com/kubernetes/kubernetes/blob/3574999fa34d54c47f43efd9eaff7e1c571c7910/examples/guestbook/php-redis/guestbook.php#L13

They use: $host = 'redis-master'; as the default method for communicating with the redis-master pod.

Which was defined in redis-master-service.yaml: https://github.com/kubernetes/kubernetes/blob/3574999fa34d54c47f43efd9eaff7e1c571c7910/examples/guestbook/redis-master-service.yaml

-- Eyal Levin
Source: StackOverflow