How to access another container in a pod

10/25/2017

I have set up a multi-container pod consisting on multiple interrelated microservices. On docker-compose if I wanted to access the another container in a compose I just use the name of the service.

I am trying to do the same thing with Kube, without having to create a pod per microservice.

I tried the name of the container or suffix with .local neither worked and I got an UnknownHostException.

My preference is also to have all the microservices runnning on port 80, but in case that does not work within a single pod, I also tried having each microservice running on it's own port and use localhost but that didn't work either it simply said connection refused (as opposed to Unknown Host)

-- Archimedes Trajano
kubernetes

1 Answer

10/30/2017

The applications in a pod all use the same network namespace (same IP and port space), and can thus “find” each other and communicate using localhost. Because of this, applications in a pod must coordinate their usage of ports.

https://kubernetes.io/docs/concepts/workloads/pods/pod/#resource-sharing-and-communication

-- delfer
Source: StackOverflow