1

I've set up a Kubernetes cluster using kubeadm using the command:

$ sudo kubeadm init --pod-network-cidr=192.168.0.0/16 --kubernetes-version=1.24.00

My cluster has 2 worker nodes, and when I run for example:

$ kubectl get node worker1 -oyaml

I can see that there's a field in the node definition .spec.podCIDR,which is set to 192.168.1.0/24.

But when running a pod on this node, I can see that it got an IP of 192.168.192.5, which is not inside the range specified in the Node definition above.

So I'm trying to understand what is the meaning of this field? The Kubernetes docs don't say too much:

podCIDR (string) PodCIDR represents the pod IP range assigned to the node.

Can someone calrify?

3 Answers 3

1

A Kubernetes cluster runs pods, and the pods need to interact with each other for application needs. This can be possible if the pods are on the same network.

Kubernetes uses container networking interface to maintain pod networks and assign IP addresses to pods. There are many CNI providers available, and a few of them are Flannel, Calico, Cilium, Weavenet, and Canal. While setting up the cluster the cluster administrator must also set up the CNI provider.

While configuring the CNI, the administrator provides a pool of IP addresses which can be assigned to pods. This pool of ip addresses are called pod cidr.

0

The podCIDR field in the Node spec in Kubernetes specifies the range of IP addresses that will be allocated to the pods running on the node.

This field is used by the Kubernetes cluster to determine how to assign IP addresses to each pod.

The podCIDR field must be unique for each node in the cluster.

1
  • Please read the question carefully
    – YoavKlein
    Commented Dec 9, 2022 at 6:21
0

some CNI implementations do not respect node.spec.podCIDR.

cilium is one example: https://docs.cilium.io/en/v1.12/concepts/networking/ipam/cluster-pool/

The difference is that instead of Kubernetes assigning the per-node PodCIDRs via the Kubernetes v1.Node resource, the Cilium operator will manage the per-node PodCIDRs via the v2.CiliumNode resource.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.