Docker Containers in Kubernetes pod not communicating

10/17/2018

I have 2 docker containers, one is running a flask server and the other is running an angular app. When I run both containers on my local system they have no trouble communicating within localhost but when I push these containers into a kubernetes pod, I get the connection refused message. Can anyone please explain what I might be doing wrong within kubernetes?

-- Jithin Thomas
docker
google-cloud-platform
kubernetes

1 Answer

10/17/2018
  • containers within the same pod share the same network namespace so there should be no issue for them to communicate over localhost , but anway in this case you should run them on separate pods

  • when you run two apps on different pods , they will need to communicate over pod IPs , Or you will need to expose them over service of type ClusterIP, or NodePort or Loadbalancer

In this case you can run them on separate pods and use cluster DNS service discovery. DNS-based service discovery provides a flexible and generic way to connect to services across the cluster.

Details:

Kubernetes service discovery by example

-- Ijaz Ahmad Khan
Source: StackOverflow