Part 3: Container Networking and Pods
In usual containerized applications eg. mysql db container,
docker run
--detach
--name=[container_name]
--env="MYSQL_ROOT_PASSWORD=my_p@ssworrD$ss"
--publish 6603:3306
--volume=/root/docker/[container_name]/conf.d:/etc/mysql/conf.d
--volume=/storage/docker/mysql-data:/var/lib/mysql
mysql:8.0
Here the host port 6603 is mapped to container port 3306. If there are 100+ containers then it will be difficult to keep track of what host ports are free and what ports are mapped on what container.
Each pod have its own ip address and it can run multiple containers.
pod is like its own virtual machine -with ip address,name space & range of ports
this allows multiple containers inside multiple pods and use same port eg. 8080 without conflicts
multiple containers inside pod can communicate with each other using localhost:port.
Pause/sandbox containers: present in each pod, its job is to reserve/hold network namespace(netns). It makes container communication possible.
If container dies the new container will be created + pod will retain its ip address
if POD gets killed the new pod will have new ip address
pod -2- pod communication
k8 dont come with container networking features
The network plugin must meet K8 requirement for Container Network Interface (CNI)plugins(link)
every pod gets it own unique ip address
pods on same or different nodes can communicate with each other using their IP addresses without NAT (should work like bridge n/w)