Suppose I have 2 containers in POD. Will each POD have a unique IP address ? If so what will be the IP addresses of each container ?
The networking namespace (IP) of pod is managed by infra container which just does nothing more than being a placeholder. All of the other Containers in pod are sharing this IP Address (Pod IP) rather than using host network namespace or host IP.
It is controlled by the following parameter of kubelet
--pod-infra-container-image
: The image whose network/ipc namespaces containers in each pod will use. (default "k8s.gcr.io/pause:3.1")
following article describe it in more detail.
In Kubernetes, the pause container serves as the "parent container" for all of the containers in your pod. The pause container has two core responsibilities. First, it serves as the basis of Linux namespace sharing in the pod. And second, with PID (process ID) namespace sharing enabled, it serves as PID 1 for each pod and reaps zombie processes. almighty-pause-container
All containers in pod share the same IP address and localhost. You must define different port number for each container.