Networking in Kubernetes
Networking in a Single Node
When Kubernetes (K8s) is installed on a host, it creates an internal private network in the range 10.244.0.0/16
. Every pod on the host receives an IP address within this network.
- The pods can communicate with each other using IP addresses, but relying on IP addresses is not advisable since they change when pods are restarted.
- Every node receives an IP address on the external network (which is separate from the K8s internal network).
Networking in a Cluster
In a multi-node cluster, each node has a unique IP address in the external network. Each node also sets up its own internal private network, which could result in overlapping CIDRs (Classless Inter-Domain Routing). This overlapping can cause IP conflicts between pods, making it impossible for pods to communicate across nodes.
When setting up a Kubernetes cluster, Kubernetes has specific networking requirements:
- All pods must be able to communicate with each other without requiring Network Address Translation (NAT).
- All nodes must be able to communicate with all the pods, and vice-versa, without requiring a NAT.
To meet these networking requirements, you can use various third-party networking solutions. These solutions ensure that each node uses a different CIDR for its internal private network, enabling proper communication between pods across different nodes.