<p>How does kubernetes pod gets IP instead of container instead of it as CNI plugin works at container level?</p>

<p>How all containers of same pod share same network stack?</p>

<p>Containers use a feature from the kernel called <strong><em>virtual network interface</em></strong>, the virtual network Interface( lets name it <strong>veth0</strong>) is created and then assigned to a namespace, when a container is created, it is also assigned to a namespace, when multiple containers are created within the same namespace, only a single network interface veth0 will be created.</p>

<p>A POD is just the term used to specify a set of resources and features, one of them is the namespace and the containers running in it.</p>

<p>When you say the POD get an IP, what actually get the ip is the veth0 interface, container apps see the veth0 the same way applications outside a container see a single physical network card on a server.</p>

<p>CNI is just the technical specification on how it should work to make multiple network plugins work without changes to the platform. The process above should be the same to all network plugins.</p>

<p>There is a nice explanation in <a href="https://medium.com/google-cloud/understanding-kubernetes-networking-pods-7117dd28727" rel="nofollow noreferrer">this blog post</a></p>
