在部署k8s集群时,个别服务器执行命令报错:

[root@lolicp ~]# kubeadm join phase control-plane-prepare download-certs --certificate-key ffee0f888dc9be0a3bac7fba43cd1543bacaa0fd546c938b0797d25549cdbcf6 --control-plane --token 5krnfb.m2llk5gf67rr1fu9 --discovery-token-unsafe-skip-ca-verification 192.168.2.111:6443
W1212 09:19:27.105088   95042 common.go:148] WARNING: could not obtain a bind address for the API Server: no default routes found in "/proc/net/route" or "/proc/net/ipv6_route"; using: 0.0.0.0
cannot use "0.0.0.0" as the bind address for the API Server
To see the stack trace of this error execute with --v=5 or higher

解决办法

这个报错是由于没有默认路由,且网关为0.0.0.0

[root@localhost ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
192.168.2.0   0.0.0.0         255.255.255.0   U     100    0        0 ens160

解决办法就是增加默认网关。

[root@hxb-node2 ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.230.2   0.0.0.0         UG    100    0        0 ens160
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
192.168.230.0   0.0.0.0         255.255.255.0   U     100    0        0 ens160
END

本文标题:kubeadm加入集群时报错cannot use "0.0.0.0" as the bind address for the API Server

本文作者:宇宙最帅的男人

本文链接:https://lolicp.com/kubernetes/202312644.html

版权声明:转载或者引用本文内容请注明来源及原作者,本文著作权归作者 (宇宙最帅的男人) 所有。

除非另有说明,本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议

最后修改:2023 年 12 月 15 日
如果觉得我的文章对你有用,请随意赞赏