failed to acquire lease: subnet "10.244.0.0/16" specified in the flannel net config doesn't contain "192.168.0.0/24"
Bogopo last edited by
I'm trying to configure Kubernetes with web dashboard. I use these steps:
Remove following line from
/swap.img none swap sw 0 0
then run these shell commands:
sudo apt update sudo apt install docker.io sudo systemctl start docker sudo systemctl enable docker sudo apt install apt-transport-https curl curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" >> ~/kubernetes.list sudo mv ~/kubernetes.list /etc/apt/sources.list.d sudo apt update sudo apt install kubeadm kubelet kubectl kubernetes-cni
sudo kubeadm init --pod-network-cidr=192.168.0.0/16
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
I applied this configuration:
kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: flannel-fix roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: flannel subjects: - kind: ServiceAccount name: flannel namespace: kube-flannel
kubectl create -f
But I get:
Error registering network: failed to acquire lease: subnet "10.244.0.0/16" specified in the flannel net config doesn't contain "192.168.0.0/24" PodCIDR of the "ubuntukubernetis1" node
Do you know what should be the correct configuration?
I figured it out by reading the documentation:
Take care that your Pod network must not overlap with any of the host networks: you are likely to see problems if there is any overlap.
Flannel uses 10.244.0.0/16 and can't run on the same as your host... it creates new interfaces when implemented. So when you run this init command it should always be using 10.244.0.0/16.
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
Once I did this, things started working as expected.