podCIDR error when creating Flannel network
Hi,
I'm creating a cluster using Kelsey Hightowers "Kubernetes the hard way", with some customization. I'm doing it locally using KVM, for instance. Also not HA. I intend it to be 1 cp master and 2 worker nodes.
I'm using this manifest for Flannel:
https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml
I've provisioned a CP master and a worker node. When I create the Flannel overlay network I get an error about podCIDR and the flannel ds does not come up.
Running: kubectl -n kube-flannel logs kube-flannel-ds-ws8lj
I get:
Error registering network: failed to acquire lease: node "c2-worker1" pod cidr not assigned
Because it's a cluster, I'm not configuring podCIDR in kubelet on the worker node:
--pod-cidr string The CIDR to use for pod IP addresses, only used in standalone mode. In cluster mode, this is obtained from the master.
https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/
I can manually add podCIDR to the node applying a patch:kubectl patch nodes c2-worker1 --patch '{"spec": {"podCIDR":"10.244.0.0/16"}}'
Then, Flannel overlay network comes up as expected.
What's happening here?
Best Answer
-
I solved it.
I needed to pass
--allocate-node-cidrs=trueto the kube-controller-manager.I'm running it as a systemd service. The start of the unit file looks like this:
[Service] ExecStart=/usr/bin/kube-controller-manager \ --cluster-cidr=10.244.0.0/16 \ --allocate-node-cidrs=true \
Now each node is assigned a /24 each and it works as expected without a manual patch.
kubectl describe nodes | grep -i cidrPodCIDR: 10.244.0.0/24 PodCIDRs: 10.244.0.0/24 PodCIDR: 10.244.1.0/24 PodCIDRs: 10.244.1.0/24
0
Answers
-
can you please mention file name to edit
0
Categories
- All Categories
- 178 LFX Mentorship
- 178 LFX Mentorship: Linux Kernel
- 773 Linux Foundation IT Professional Programs
- 383 Cloud Engineer IT Professional Program
- 175 Advanced Cloud Engineer IT Professional Program
- 75 DevOps IT Professional Program - Discontinued
- 7 DevOps & GitOps IT Professional Program
- 102 Cloud Native Developer IT Professional Program
- 7.6K Training Courses & Learning Paths
- 9 AI & ML Training
- 1 Blockchain & Decentralized Identity Training
- 28 Cloud & Containers Training
- 3 Cybersecurity Training
- 2 DevOps & Site-Reliability Training
- 1 Linux Kernel Development Training
- 2 Networking Training
- 2 Open Source Best Practice Training
- 5 System Administration Training
- 1 System Engineering Training
- 4 Web & Application Development Training
- 798 Hardware
- 202 Drivers
- 68 I/O Devices
- 37 Monitors
- 96 Multimedia
- 173 Networking
- 91 Printers & Scanners
- 92 Storage
- 771 Linux Distributions
- 81 Debian
- 68 Fedora
- 23 Linux Mint
- 13 Mageia
- 24 openSUSE
- 151 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 356 Ubuntu
- 469 Linux System Administration
- 31 Cloud Computing
- 73 Command Line/Scripting
- Github systems admin projects
- 101 Linux Security
- 79 Network Management
- 101 System Management
- 46 Web Management
- 149 Mobile Computing
- 20 Android
- 114 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 404 Off Topic
- 126 Introductions
- 34 Study Material
- 1K Programming and Development
- 310 Kernel Development
- 717 Software Development
- 1K Software
- 416 Applications
- 182 Command Line
- 5 Compiling/Installing
- 71 Games
- 320 Installation
- Archived
- 183 Small Talk
- 2 LFD140 Class Forum
- 1.4K LFS258 Class Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)