Docker/Kubernetes - how to share dns names between containers?

6/27/2018

I have a newbie question about Docker and Kubernetes.

For example I have three PHP services in different containers. Nginx and php-fpm are in different containers too for each PHP service (1 process = 1 container).

Each PHP service should know the DNS name of the other PHP services in the cluster - how can I solve this? How should I configure the cluster and containers/pods to make it possible?

Thank you in advance for you help.

Sincerely,

gtw000

--
docker
kubernetes

1 Answer

6/27/2018

Kubernetes services create a DNS record that resolves to an IP. When you communicate with this IP the request reaches one of the pods the service is targeted on.

For example, if you have the following services: svc1, svc2 and svc3 svc1 should be a resolvable hostname that directs the traffic to one of svc1's pods The same goes for svc2 and svc3

Please read further on K8s Services Docs

-- Erez Rabih
Source: StackOverflow