Pods scheduled to a node receive an IP address from the node's Pod CIDR range. At this point pods can not communicate with other pods running on different nodes due to missing routes which is responsible to do NAT
In this lab you will create a route for each worker node that routes Pod IP to 192.168.78.0/24 network .
There are other ways to implement the Kubernetes networking model.
In this section you will gather the information required to create routes in the worker nodes.
IP address and Pod CIDR range for each worker instance:
+------------+------------------+----------------+
| Worker | IP Address | Pod CIDR |
+------------+------------------+----------------+
| worker-01 | 192.168.78.211 | 10.10.1.0/24 |
| worker-02 | 192.168.78.212 | 10.10.2.0/24 |
| worker-03 | 192.168.78.213 | 10.10.3.0/24 |
+------------+------------------+----------------+
Create network routes for each worker instance:
ROUTE_DATA="worker-01,192.168.78.211,10.10.1.0/24
worker-02,192.168.78.212,10.10.2.0/24
worker-03,192.168.78.213,10.10.3.0/24"
for instance in worker-01 worker-02 worker-03
do
ROUTE_MINI=$(echo "${ROUTE_DATA}" | grep -v -w ${instance})
for ROUTE in ${ROUTE_MINI}
do
echo "#### Adding Route for ${instance} ####"
NET=$(echo ${ROUTE} |awk -F "," '{print $3}')
GW=$(echo ${ROUTE} |awk -F "," '{print $2}')
ssh -t k8s@${instance} sudo -i "echo -e \"\tpost-up route add -net ${NET} gw ${GW}\"|sudo tee --append /etc/network/interfaces"
ssh -t k8s@${instance} sudo -i "route add -net ${NET} gw ${GW}"
done
done
List all routes
for instance in worker-01 worker-02 worker-03; do ssh k8s@${instance} "ip route show|grep ^10.10"; done
- Output
k8s@worker-01's password:
10.10.2.0/24 via 192.168.78.212 dev enp0s8
10.10.3.0/24 via 192.168.78.213 dev enp0s8
k8s@worker-02's password:
10.10.1.0/24 via 192.168.78.211 dev enp0s8
10.10.3.0/24 via 192.168.78.213 dev enp0s8
k8s@worker-03's password:
10.10.1.0/24 via 192.168.78.211 dev enp0s8
10.10.2.0/24 via 192.168.78.212 dev enp0s8
Part 12 - Deploying the DNS Cluster Add-on