2017-08-29 00:19:25 +03:00
# Provisioning Pod Network Routes
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 ](https://cloud.google.com/compute/docs/vpc/routes ).
In this lab you will create a route for each worker node that maps the node's Pod CIDR range to the node's internal IP address.
> There are [other ways](https://kubernetes.io/docs/concepts/cluster-administration/networking/#how-to-achieve-this) to implement the Kubernetes networking model.
2024-01-29 20:57:45 +03:00
## The Routing Table (GCloud Only)
2017-08-29 00:19:25 +03:00
In this section you will gather the information required to create routes in the `kubernetes-the-hard-way` VPC network.
Print the internal IP address and Pod CIDR range for each worker instance:
```
for instance in worker-0 worker-1 worker-2; do
gcloud compute instances describe ${instance} \
--format 'value[separator=" "](networkInterfaces[0].networkIP,metadata.items[0].value)'
done
```
> output
```
10.240.0.20 10.200.0.0/24
10.240.0.21 10.200.1.0/24
10.240.0.22 10.200.2.0/24
```
## Routes
Create network routes for each worker instance:
2024-01-29 20:57:45 +03:00
```gcloud```
2017-08-29 00:19:25 +03:00
```
for i in 0 1 2; do
gcloud compute routes create kubernetes-route-10-200-${i}-0-24 \
--network kubernetes-the-hard-way \
--next-hop-address 10.240.0.2${i} \
--destination-range 10.200.${i}.0/24
done
```
2024-01-29 20:57:45 +03:00
```az```
```
az network route-table create \
--name k8s-the-hard-way-route-table
for i in 0 1 2; do
az network route-table route create \
--name kubernetes-route-10-200-${i}-0-24 \
--route-table-name k8s-the-hard-way-route-table \
--address-prefix 10.200.${i}.0/24 \
--next-hop-ip-address 10.240.0.2${i} \
--next-hop-type VirtualAppliance
done
az network vnet subnet update \
--vnet-name kubernetes-the-hard-way \
--name kubernetes \
--route-table k8s-the-hard-way-route-table
```
2017-08-29 00:19:25 +03:00
List the routes in the `kubernetes-the-hard-way` VPC network:
```
2017-10-02 06:37:09 +03:00
gcloud compute routes list --filter "network: kubernetes-the-hard-way"
2017-08-29 00:19:25 +03:00
```
> output
```
NAME NETWORK DEST_RANGE NEXT_HOP PRIORITY
2021-05-02 08:33:46 +03:00
default-route-1606ba68df692422 kubernetes-the-hard-way 10.240.0.0/24 kubernetes-the-hard-way 0
default-route-615e3652a8b74e4d kubernetes-the-hard-way 0.0.0.0/0 default-internet-gateway 1000
2017-08-29 00:19:25 +03:00
kubernetes-route-10-200-0-0-24 kubernetes-the-hard-way 10.200.0.0/24 10.240.0.20 1000
kubernetes-route-10-200-1-0-24 kubernetes-the-hard-way 10.200.1.0/24 10.240.0.21 1000
kubernetes-route-10-200-2-0-24 kubernetes-the-hard-way 10.200.2.0/24 10.240.0.22 1000
```
Next: [Deploying the DNS Cluster Add-on ](12-dns-addon.md )