Container-to-container communication
Pods can have multiple containers and a pod has its network namespace (netns).
Network namespaces enable you to have network interfaces and IP tables that are independent of the host environment (i.e., the K8s worker node).
Containers inside a pod share the same networking namespace. Because of the shared networking namespace, containers get access to the same network resources, such as the IP address and ports through the same IP table routing logic.
Each container inside the pod can communicate via localhost as if they are part of the same netns.
As shown in the following figure, the containers inside a pod share the same netns:
Figure 4.9 – Container-to-container communication
Having learned how containers communicate with each other, now it is time to look into how pods communicate with each other.