查看kube-controller-manager 报错, 说ip地址段已经没有可用的ip了
[root@master1 ~]# journalctl -f -t kube-controller-manager -- Logs begin at 日 2021-09-12 12:29:49 CST. -- 9月 23 13:26:43 master1 kube-controller-manager[1282]: E0923 13:26:43.273721 1282 controller_utils.go:260] Error while processing Node Add/Delete: failed to allocate cidr from cluster cidr at idx:0: CIDR allocation failed; there are no remaining CIDRs left to allocate in the accepted range 9月 23 13:26:43 master1 kube-controller-manager[1282]: I0923 13:26:43.273889 1282 event.go:291] "Event occurred" object="master1" kind="Node" apiVersion="v1" type="Normal" reason="CIDRNotAvailable" message="Node master1 status is now: CIDRNotAvailable" 9月 23 13:26:58 master1 kube-controller-manager[1282]: I0923 13:26:58.086189 1282 controller_utils.go:185] Recording status change CIDRNotAvailable event message for node node2 9月 23 13:26:58 master1 kube-controller-manager[1282]: E0923 13:26:58.086245 1282 controller_utils.go:260] Error while processing Node Add/Delete: failed to allocate cidr from cluster cidr at idx:0: CIDR allocation failed; there are no remaining CIDRs left to allocate in the accepted range 9月 23 13:26:58 master1 kube-controller-manager[1282]: I0923 13:26:58.086424 1282 event.go:291] "Event occurred" object="node2" kind="Node" apiVersion="v1" type="Normal" reason="CIDRNotAvailable" message="Node node2 status is now: CIDRNotAvailable"9月 23 13:27:08 master1 kube-controller-manager[1282]: I0923 13:27:08.463702 1282 controller_utils.go:185] Recording status change CIDRNotAvailable event message for node master2 9月 23 13:27:08 master1 kube-controller-manager[1282]: E0923 13:27:08.463757 1282 controller_utils.go:260] Error while processing Node Add/Delete: failed to allocate cidr from cluster cidr at idx:0: CIDR allocation failed; there are no remaining CIDRs left to allocate in the accepted range 9月 23 13:27:08 master1 kube-controller-manager[1282]: I0923 13:27:08.464029 1282 event.go:291] "Event occurred" object="master2" kind="Node" apiVersion="v1" type="Normal" reason="CIDRNotAvailable" message="Node master2 status is now: CIDRNotAvailable"
kube-controller-manager 配置文件中, 修改cluster-cidr 使用了一个C
[Service] ExecStart=/usr/local/bin/kube-controller-manager --leader-elect=true --kubeconfig=/etc/kubernetes/kube-controller-manager.kubeconfig --bind-address=192.168.15.131 --allocate-node-cidrs=true --cluster-cidr=192.168.56.0/24 --secure-port=10257
kube-controller-manager 分配pod网段, 默认每个node上的pod都会分配一个C段, 如果只有一个,那么需要设置子网--node-cidr-mask-size
k8s集群中使用了7台服务器搭建, 那么需要 254/7 子网为27位, 每台机器上分配30个IP
修改 kube-controller-manager 配置文件,添加红色部分
[Service] ExecStart=/usr/local/bin/kube-controller-manager --leader-elect=true --kubeconfig=/etc/kubernetes/kube-controller-manager.kubeconfig --bind-address=192.168.15.131 --allocate-node-cidrs=true --cluster-cidr=192.168.56.0/24 --node-cidr-mask-size-ipv4=27 --secure-port=10257
重启 kube-controller-manager
systemctl daemon-reload
systemctl restart kube-controller-manager