How kubernetes assigns podCIDR for nodes?

uxhixvfz  于 2022-12-11  发布在  Kubernetes
关注(0)|答案(1)|浏览(152)

I'm currently learning about Kubernetes networking.
What I've got so far, is that we have CNI plugins which takes care of handling network connectivity for pods - they create network interfaces inside a network namespace when a pod is created, they set up routes for the pod, etc. So basically kubernetes delegates some network-related tasks to the CNI plugins.
But I suppose there is some portion of networking tasks that kubernetes does by itself. For example - kubernetes assigns to each node a podCIDR .
For example, I've set up a kubernetes cluster using kubeadm, with the command:

kubeadm init --pod-network-cidr=192.168.0.0/16 --kubernetes-version=1.24.0

And when I then look at the nodes I see that each received its own podCIDR range, for example:

spec:
    podCIDR: 192.168.2.0/24
    podCIDRs:
    - 192.168.2.0/24

My question is: How does kubernetes calculate CIDR ranges for the nodes? Does it always assign a /24 subnet for each node?

jc3wubiy

jc3wubiy1#

为群集配置每个节点的最大Pod数时,Kubernetes将使用此值为节点分配CIDR范围。您可以根据群集的Pod辅助IP地址范围和为节点分配的CIDR范围计算群集上的最大节点数。
Kubernetes为每个节点分配一个IP地址范围和一个CIDR块,以便每个Pod都有一个唯一的IP地址。CIDR块的大小与每个节点的最大Pod数相对应。
也请参阅类似的SO & CIDR ranges以获取更多信息。

相关问题