简体   繁体   中英

Docker Containers in Kubernetes pod not communicating

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?

  • 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM