关于kubernetes apiserver服务启动不了


在本地虚拟机上安装无问题,是按照官方文档进行安装,ip分配方式是DHCP
在内网服务器上,桥接网络,安装kubernetes完成后,此时ip分配方式仍然是DHCP,启动无错,但是修改ip成static 重启network 重启apiserver,此时 apiserver启动失败。。。
难道kubernetes 一定要有DHCP服务吗?
有哪位路过的大神遇到过这样的问题
master 和 minion 是内网交换机链接的(没有使用路由)

Dec 16 23:34:06 localhost kube-apiserver: F1216 23:34:06.903901 2995 controller.go:80] Unable to perform initial IP allocation check: unable to refresh the service IP block: 501: All the given peers are not reachable (failed to propose on members [http://192.168.192.138:2379] twice [last error: Get http://192.168.192.138:2379/v2 ... alse: dial tcp 192.168.192.138:2379: connection refused]) [0]
已邀请:

henryrao - 一個月內拿下k8s

赞同来自: zhuwz


参考这篇文件的这段networkd and DHCP behavior,原文提到


By default, even if you've already set a static IP address and you have a working DHCP server in your network, systemd-networkd will nevertheless assign IP address using DHCP. If you would like to remove this address, you have to use the following cloud-config example:
大致说如果你的网路环境下有DHCP服务器,即使你手动设置的静态ip地址,那systemd-networkd还是先用DHCP分发的ip地址. 这是个坑呀!!!

这是我安装coreos的cloud-init.yaml档案的截取内容

以下过程执行了
1. 先停止systemd-networkd
2. 利用00-enp0s3.network配置一个静态ip
3. down-interfaces.service用来重置网卡设备
4. 再重新启动systemd-networkd

units:
- name: "systemd-networkd.service"
  command: "stop"
- name: "00-enp0s3.network"
  runtime: true
  content: |
    [Match]
    Name=enp0s3 #确认自己的网卡名称

    [Network]
    DNS=192.168.31.1 #自行修改
    Address=192.168.31.244/24  #修改成你的
    Gateway=192.168.31.1  #自行修改
- name: "down-interfaces.service"
  command: "start"
  content: |
    [Service]
    Type=oneshot
    ExecStart=/usr/bin/ip link set enp0s3 down  #确认自己的网卡名称
    ExecStart=/usr/bin/ip addr flush dev enp0s3  #确认自己的网卡名称
- name: "systemd-networkd.service"
  command: "restart"

期望能帮到你,如有不正确之处也请订正

wulonghui - PaaS工程师

赞同来自:


Dec 16 23:34:06 localhost kube-apiserver: F1216 23:34:06.903901 2995 controller.go:80] Unable to perform initial IP allocation check: unable to refresh the service IP block: 501: All the given peers are not reachable (failed to propose on members [http://192.168.192.138:2379] twice [last error: Get http://192.168.192.138:2379/v2 ... alse: dial tcp 192.168.192.138:2379: connection refused]) [0]

这个是连不上ETCD的保持

beyondblog - 标准90后有为青年

赞同来自:


192.168.192.138 netstat -natp | grep etcd 看看监听的ip和端口是不是正确的

要回复问题请先登录注册