Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 497
Chris Stryczynski Avatar asked Jul 02 '18 18:07

Chris Stryczynski


People also ask

How do I check my pod network CIDR in Kubernetes?

To get Service IP range - i.e. IP's assigned to ClusterIP, the command is: ps -aux | grep kube-apiserver | grep service-cluster-ip-range (you can run this on master node) cat /etc/kubernetes/manifests/kube-apiserver. yaml | grep service-cluster-ip-range.

What is POD CIDR in Kubernetes?

Kubernetes assigns each node a range of IP addresses, a CIDR block, so that each Pod can have a unique IP address. The size of the CIDR block corresponds to the maximum number of Pods per node.

Where can I find Kubernetes CIDR?

To find the cluster IP address of a Kubernetes pod, use the kubectl get pod command on your local machine, with the option -o wide . This option will list more information, including the node the pod resides on, and the pod's cluster IP. The IP column will contain the internal cluster IP address for each pod.


1 Answers

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.

like image 128
the_marcelo_r Avatar answered Sep 26 '22 07:09

the_marcelo_r