How can I determine an appropriate pod CIDR value for a Kubernetes cluster?

Chris Stryczynski picture Chris Stryczynski · Jul 2, 2018 · Viewed 10.8k times · Source

I'm initiating a kubernetes cluster with:

kubeadm init --pod-network-cidr=192.168.1.0/16 --apiserver-advertise-address=192.168.0.33

I'm not too familiar with networking concepts or CIDR, how do I determine an appropriate value for the pod CIDR?

I previously used 10.244.0.0/16 but that resulted in:

Failed create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "78cf556b2e87e15cc5ec8827ca3a397c16dcfb90f045e225a17028f072db6e5f" network for pod "coredns-78fcdf6894-c7kq2": NetworkPlugin cni failed to set up pod "coredns-78fcdf6894-c7kq2_kube-system" network: failed to set bridge addr: "cni0" already has an IP address different from 10.244.1.1/24

Answer

the_marcelo_r picture the_marcelo_r · Jul 2, 2018

Regarding CIDR (Classless Inter-Domain Routing): That is just a notation to define the subnet / range of IP addresses that you want to use in your network.

If you want to use /16, you must be planning the creation of a fairly big Kubernetes cluster since that will give you >65k virtual IP addresses (Note that we are talking about the SDN / Virtual network, i.e., the IPs you will set for your kubernetes PODs, not your actual nodes / hosts). Here is a CIDR table you can use as reference to decide a more suitable range: https://kb.wisc.edu/ns/page.php?id=3493

Now, in terms of your failure that depends on the CNI (Container Networking Interface) plugin you are using in your Kubernetes cluster. If you are using the default one that must be Kubenet, which has limitations. More information here: https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/ and here: https://chrislovecnm.com/kubernetes/cni/choosing-a-cni-provider/

I hope that helps.