kubernetes API Server 没有 bind 0.0.0.0

今天早上改动态IP为静态IP,之前都是动态的,每次重启电脑IP虚拟机的IP就变了导致要修改master IP,所以改为静态的

切换到

cd /etc/sysconfig/network-scripts/

修改配置文件

ifcfg-ens160(当然这个文件每一个系统可能不一样),添加如下内容(为自己的ip,可以用ipconfig /all 或者ifconfig 查询下IP信息):

IPADDR="192.168.93.116"        # 设置的静态IP地址
NETMASK="255.255.255.0"         # 子网掩码
GATEWAY="192.168.93.255"         # 网关地址
DNS1="192.168.93.1"            # DNS服务器

 修改完成之后,然后添加集群节点,就报错

15409 join.go:413] [preflight] found NodeName empty; using OS hostname as NodeName
I0903 04:12:18.403457   15409 join.go:417] [preflight] found advertiseAddress empty; using default interface's IP address as advertiseAddress
I0903 04:12:18.404096   15409 initconfiguration.go:117] detected and using CRI socket: unix:///var/run/containerd/containerd.sock
W0903 04:12:18.404239   15409 common.go:169] 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

这个问题是由于没有正确添加网关造成的,route -n

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.93.0    0.0.0.0         255.255.255.0   U     100    0        0 ens160
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0

因为我用的是虚拟机,用的是和主机一样的网络,所以ipconfig  /all 查看所有的信息,找到了网关应该为192.168.93.1

修改网关地址为

GATEWAY="192.168.93.1"         # 网关地址

重启。

重启之后发现多了一条路由。

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.93.1    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.93.0    0.0.0.0         255.255.255.0   U     100    0        0 ens160
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0

还有一种方式,直接添加路由:

估计执行如下命令也是可以的
route add default gw 192.168.93.1 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值