K8S集群部署flannel分配IP冲突的解决方法
程序员文章站
2024-03-12 16:59:32
...
这两天在为集群里的node部署flannel时碰到个很狗血的错误,在其中一台node启动flannel后,其它任意一台都无法再加入子网,输出错误如下:
7月 13 11:21:44 node-2 flanneld-start[69862]: I0713 11:21:44.709794 69862 local_manager.go:179] Picking subnet in range 173.28.1.0 ... 173.28.0.0
7月 13 11:21:44 node-2 flanneld-start[69862]: E0713 11:21:44.709856 69862 network.go:102] failed to register network: failed to acquire lease: out of subnets
7月 13 11:21:45 node-2 flanneld-start[69862]: I0713 11:21:45.711991 69862 local_manager.go:179] Picking subnet in range 173.28.1.0 ... 173.28.0.0
7月 13 11:21:45 node-2 flanneld-start[69862]: E0713 11:21:45.712011 69862 network.go:102] failed to register network: failed to acquire lease: out of subnets
7月 13 11:21:46 node-2 flanneld-start[69862]: I0713 11:21:46.718920 69862 local_manager.go:179] Picking subnet in range 173.28.1.0 ... 173.28.0.0
7月 13 11:21:46 node-2 flanneld-start[69862]: E0713 11:21:46.719033 69862 network.go:102] failed to register network: failed to acquire lease: out of subnets
7月 13 11:21:47 node-2 flanneld-start[69862]: I0713 11:21:47.725058 69862 local_manager.go:179] Picking subnet in range 173.28.1.0 ... 173.28.0.0
7月 13 11:21:47 node-2 flanneld-start[69862]: E0713 11:21:47.725118 69862 network.go:102] failed to register network: failed to acquire lease: out of subnets
7
原因是172.28.1.0这个IP已经被分配给了第一台连接的主机,检查etcd发现subnets下仅有一个IP段:
[[email protected] ~]# etcdctl get /flannel/network/config
{"Network":"173.28.0.0/24"}
[[email protected] ~]# etcdctl ls /flannel/network/subnets/
/flannel/network/subnets/172.18.0.128-25
后来查资料发现flannel在ETCD中的SubnetLen参数缺省值是24,怀疑跟IP池分配冲突,于是调整参数为{"Network":"173.28.0.0/16"}
问题解决。
值于为什么SubnetLen和分配IP池相同会导致此种错误,暂不清楚
上一篇: 老生常谈PHP 文件写入和读取(必看篇)