Basics of Kubernetes Networking
- A Kubernetes node has an IP address. We can use the IP address to access the Kubenretes node, ssh into it, etc.
- A pod hosts a container. The IP address is assigned to a pod unlike Docker world where an IP address is always assigned to a Docker container.
- Each pod in the Kubernetes cluster gets its own internal IP address (starting with 10.244.x.x..).
- An internal private network is initially created with address 10.244.0.0 and all the pods are attached to it.
- Multiple pods will get assigned different IP address within this internal network.
- The pods can communicate to each other through this IP addresses.
- When pods are recreated, the IP address change.
How the Internal Networking Works in Kubernetes (Cluster Networking)
Q: What happens when there are multiple nodes in the Kubernetes cluster?
- When a Kubernetes cluster is set up, Kubernetes does not automatically set up any kind of networking.
- Kubernetes expects users to set up networking to meet certain fundamental requirements.
Fundamental requirements:
- All containers/Pods can comunicate to one another without NAT
- All nodes can communicate with all containers and vice-cersa without NAT
- Fortunately, there are multiple pre-built solutions available for this
- They help manage the networks and IP addresses in the network and assign a different network address for each network
- This creates a virtual network of all pods and nodes where they are assigned an unique IP address.
- This uses simple routing techniques, the cluster networking enables communication between the different pods or nodes.
- As a result, all the pods can communicate to each other using the assigned IP address.