Problems with pod-network in kubernetes

6/29/2018

I created 3 vbox VM for testing k8s. Each vm has 2 netwoks: Nat and internal. K8s was initialized with:

kubeadm init --apiserver-advertise-address 192.168.1.1 --service-cidr 192.168.1.0/24 --pod-network-cidr 192.168.1.0/24

192.168.1.0/24 is the internal network. Nodes were joined by

kubeadm join 192.168.1.1:6443 --token some_token --discovery-token-ca-cert-hash hash

When I'm trying to deploy flannel I get errors like:

I0629 09:25:06.640787       1 main.go:475] Determining IP address of default interface
I0629 09:25:06.645316       1 main.go:488] Using interface with name enp0s3 and address 10.0.2.15
I0629 09:25:06.645335       1 main.go:505] Defaulting external address to interface address (10.0.2.15)
I0629 09:25:06.656691       1 kube.go:131] Waiting 10m0s for node controller to sync
I0629 09:25:06.656794       1 kube.go:294] Starting kube subnet manager
I0629 09:25:07.657778       1 kube.go:138] Node controller sync successful
I0629 09:25:07.657795       1 main.go:235] Created subnet manager: Kubernetes Subnet Manager - kub2
I0629 09:25:07.657798       1 main.go:238] Installing signal handlers
I0629 09:25:07.657892       1 main.go:353] Found network config - Backend type: vxlan
I0629 09:25:07.657928       1 vxlan.go:120] VXLAN config: VNI=1 Port=0 GBP=false DirectRouting=false
E0629 09:25:07.658039       1 main.go:280] Error registering network: failed to acquire lease: node "kub2" pod cidr not assigned

what am I doing wrong?

-- Kirill Ponomarev
kubeadm
kubernetes

1 Answer

6/29/2018

As per error string in your logs:

E0629 09:25:07.658039 1 main.go:280] Error registering network: failed to acquire lease: node "kub2" pod cidr not assigned

It seems you used subnet 192.168.1.0/24 which was fully distributed for master node creation; however, there were not enough IP pools for work nodes building, as by default kube-controller-manager gives /24 network for each node. As the solution, you can use wider network subnet addressing, and also be aware that subnets you intend to use can't be a part of each other.

For example, if you have your local network 192.168.1.0/24, --pod-network-cidr should be like 192.168.2.0/24 and --pod-network-cidr like 172.17.0.0/16

-- mk_sta
Source: StackOverflow