kubernetes-the-hard-way/docs/11-pod-network-routes.md

47 lines
1.3 KiB
Markdown
Raw Normal View History

# Adding Pod Network Routes
2017-08-29 00:19:25 +03:00
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 network routes.
2017-08-29 00:19:25 +03:00
In this chapter, you will create routes for each worker node that maps the node's Pod CIDR range to the node's IP address.
2017-08-29 00:19:25 +03:00
> There are [other ways](https://kubernetes.io/docs/concepts/cluster-administration/networking/#how-to-achieve-this) to implement the Kubernetes networking model.
*The instructions in this chapter should be done in the host, not in the virtual machines.*
2017-08-29 00:19:25 +03:00
## Routes
2017-08-29 00:19:25 +03:00
Get the bridge name of `kubernetes-nw`.
2017-08-29 00:19:25 +03:00
```
$ KUBERNETES_BRIDGE=$(sudo virsh net-info kubernetes-nw | grep Bridge | awk '{ print $2}')
2017-08-29 00:19:25 +03:00
```
Create network routes for each worker instance:
```
$ for i in 1 2 3; do
sudo ip route add 10.200.${i}.0/24 via 10.240.0.2${i} dev ${KUBERNETES_BRIDGE}
2017-08-29 00:19:25 +03:00
done
```
List the routes in the host:
2017-08-29 00:19:25 +03:00
```
$ ip route
2017-08-29 00:19:25 +03:00
```
> output
```
default via 172.16.0.1 dev wlp4s0 proto dhcp metric 600
10.200.1.0/24 via 10.240.0.21 dev virbr1
10.200.2.0/24 via 10.240.0.22 dev virbr1
10.200.3.0/24 via 10.240.0.23 dev virbr1
10.240.0.0/24 dev virbr1 proto kernel scope link src 10.240.0.1
(...)
2017-08-29 00:19:25 +03:00
```
Next: [Deploying the DNS Cluster Add-on](12-dns-addon.md)