Is there any direct command to fetch the podcidr assigned to each node when using calico CNI.
I am looking for exact network and netmask assigned to each node. I am not able to fetch it from kubectl get nodes
neither via podCIDR value
nor via projectcalico.org/IPv4VXLANTunnelAddr
annotation. Also looks like the annotation will also differ based on VXLAN or IPIP tunnel used by calico.
Tried to fetch via podCIDR key from nodes. Got the following output. Which wasn't the network assigned to the nodes.
kubectl get nodes -oyaml | grep -i podcidr -B 1
spec:
podCIDR: 192.168.0.0/24
podCIDRs:
--
spec:
podCIDR: 192.168.2.0/24
podCIDRs:
Tried to fetch it via calico annotation. Was able to find the network but the netmask was missing.
kubectl get nodes -oyaml | grep -i ipv4vxlan
projectcalico.org/IPv4VXLANTunnelAddr: 192.168.33.64
projectcalico.org/IPv4VXLANTunnelAddr: 192.168.253.192
Tried to fetch it via calico pod. Found the exact network and netmask i.e 192.168.33.64/26 from the calico log.
kubectl logs calico-node-h2s9w -n calico-system | grep cidr
2020-12-14 06:54:50.783 [INFO][18] tunnel-ip-allocator/ipam.go 140:
Attempting to load block cidr=192.168.33.64/26 host="calico-master"
But i want to avoid looking at logs of calico pod on each node. Is there a better way to find the podcidr assigned to each node via a single command.
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.
Command to fetch the exact podcidr and nodeip: