Test networking
In this lab we will test the Calico cluster to demonstrate networking is working correctly.
Pod to pod pings
Create three busybox instances
kubectl run pingtest --image=busybox --replicas=3 -- sleep infinity
Check their IP addresses
kubectl get pod -l run=pingtest -o wide
Result
Note the IP addresses of the second two pods, then exec into the first one. For example
kubectl exec -ti pingtest-b4b6f8cf-b5z78 sh
From inside the pod, ping the other two pod IP addresses. For example
ping 192.168.45.193 -c 4
Result
Check routes
From one of the nodes, verify that routes exist to each of the pingtest
pods’ IP addresses. For example
ip route get 192.168.38.128
Result
The via 172.31.37.123
in this example indicates the next-hop for this pod IP, which matches the IP address of the node the
pod is scheduled on, as expected.
IPAM allocations from different pools
Recall that we created two IP pools, but left one disabled.
calicoctl get ippools -o wide
Result
Enable the second pool.
calicoctl apply -f - <<EOF
apiVersion: projectcalico.org/v3
kind: IPPool
metadata:
name: pool2
spec:
cidr: 192.168.192.0/19
ipipMode: Never
natOutgoing: true
disabled: false
nodeSelector: all()
EOF
Create a pod, explicitly requesting an address from pool2
kubectl apply -f - <<EOF
apiVersion: v1
kind: Pod
metadata:
name: pingtest-pool2
annotations:
cni.projectcalico.org/ipv4pools: "[\"pool2\"]"
spec:
containers:
- args:
- sleep
- infinity
image: busybox
imagePullPolicy: Always
name: pingtest
EOF
Verify it has an IP address from pool2
kubectl get pod pingtest-pool2 -o wide
Result
From one of the original pingtest pods, ping the IP address.
ping 192.168.219.0 -c 4
Result
Clean up
kubectl delete deployment pingtest
kubectl delete pod pingtest-pool2