How to find out what podcidr is assigned to each node by calico CNI in kubernetes
You can use etcdctl
to know details of subnet block assigned to each node.
ETCDCTL_API=3 etcdctl ls /calico/ipam/v2/host/node1/ipv4/block/
Above example for a node node1
will give something like below as output.
/calico/ipam/v2/host/node1/ipv4/block/192.168.228.192-26
Looks like calico adds a custom resource called ipamblocks and it contains the podcidr assigned to each cluster node.
The name of the custom resource itself contains the node's podcidr.
kubectl get ipamblocks.crd.projectcalico.org NAME AGE10-42-123-0-26 89d10-42-187-192-26 89d
Command to fetch the exact podcidr and nodeip:
kubectl get ipamblocks.crd.projectcalico.org -o jsonpath="{range .items[*]}{'podNetwork: '}{.spec.cidr}{'\t NodeIP: '}{.spec.affinity}{'\n'}"
podNetwork: 10.42.123.0/26 NodeIP: host:<node1-ip>podNetwork: 10.42.187.192/26 NodeIP: host:<node2-ip>