在部署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
文章来源于互联网:kubeadm加入集群时报错cannot use “0.0.0.0” as the bind address for the API Server