代码之家  ›  专栏  ›  技术社区  ›  Akshay Sood

kubeadm init显示kubelet没有运行或健康

  •  2
  • Akshay Sood  · 技术社区  · 6 年前

    我在试着运行库伯内特斯和尝试使用 sudo kubeadm init 根据官方文件的建议,交换是关闭的。

    [kubelet-check] It seems like the kubelet isn't running or healthy.
    [kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get http://localhost:10248/healthz: dial tcp 127.0.0.1:10248: connect: connection refused.
    [kubelet-check] It seems like the kubelet isn't running or healthy.
    [kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get http://localhost:10248/healthz: dial tcp 127.0.0.1:10248: connect: connection refused.
    [kubelet-check] It seems like the kubelet isn't running or healthy.
    [kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get http://localhost:10248/healthz: dial tcp 127.0.0.1:10248: connect: connection refused.
    [kubelet-check] It seems like the kubelet isn't running or healthy.
    [kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get http://localhost:10248/healthz: dial tcp 127.0.0.1:10248: connect: connection refused.
    [kubelet-check] It seems like the kubelet isn't running or healthy.
    [kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get http://localhost:10248/healthz: dial tcp 127.0.0.1:10248: connect: connection refused.
    
    
    Unfortunately, an error has occurred:
                timed out waiting for the condition
    
    This error is likely caused by:
                - The kubelet is not running
                - The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)
                - No internet connection is available so the kubelet cannot pull or find the following control plane images:
                    - k8s.gcr.io/kube-apiserver-amd64:v1.11.2
                    - k8s.gcr.io/kube-controller-manager-amd64:v1.11.2
                    - k8s.gcr.io/kube-scheduler-amd64:v1.11.2
                    - k8s.gcr.io/etcd-amd64:3.2.18
                    - You can check or miligate this in beforehand with "kubeadm config images pull" to make sure the images
                      are downloaded locally and cached.
    
            If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
                - 'systemctl status kubelet'
                - 'journalctl -xeu kubelet'
    
            Additionally, a control plane component may have crashed or exited when started by the container runtime.
            To troubleshoot, list all containers using your preferred container runtimes CLI, e.g. docker.
            Here is one example how you may list all Kubernetes containers running in docker:
                - 'docker ps -a | grep kube | grep -v pause'
                Once you have found the failing container, you can inspect its logs with:
                - 'docker logs CONTAINERID'
    couldn't initialize a Kubernetes cluster
    

    我使用的docker版本是 Docker version 17.03.2-ce, build f5ec1e2 我使用的是64位的Ubuntu 16.04 LTS

    docker图像显示以下图像:

    REPOSITORY                                 TAG                 IMAGE ID            CREATED             SIZE
    k8s.gcr.io/kube-apiserver-amd64            v1.11.2             821507941e9c        3 weeks ago         187 MB
    k8s.gcr.io/kube-controller-manager-amd64   v1.11.2             38521457c799        3 weeks ago         155 MB
    k8s.gcr.io/kube-proxy-amd64                v1.11.2             46a3cd725628        3 weeks ago         97.8 MB
    k8s.gcr.io/kube-scheduler-amd64            v1.11.2             37a1403e6c1a        3 weeks ago         56.8 MB
    k8s.gcr.io/coredns                         1.1.3               b3b94275d97c        3 months ago        45.6 MB
    k8s.gcr.io/etcd-amd64                      3.2.18              b8df3b177be2        4 months ago        219 MB
    k8s.gcr.io/pause                           3.1                 da86e6ba6ca1        8 months ago        742 kB
    

    完整日志可在以下位置找到: https://pastebin.com/T5V0taE3

    编辑:

    ubuntu@ubuntu-HP-Pavilion-15-Notebook-PC:~$ docker ps -a
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS
    

    记者:xeu kubelet 输出:

    journalctl -xeu kubelet
    -- Subject: Unit kubelet.service has finished shutting down
    -- Defined-By: systemd
    -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
    -- 
    -- Unit kubelet.service has finished shutting down.
    Sep 01 10:40:05 ubuntu-HP-Pavilion-15-Notebook-PC systemd[1]: Started kubelet: T
    -- Subject: Unit kubelet.service has finished start-up
    -- Defined-By: systemd
    -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
    -- 
    -- Unit kubelet.service has finished starting up.
    -- 
    -- The start-up result is done.
    Sep 01 10:40:06 ubuntu-HP-Pavilion-15-Notebook-PC kubelet[9107]: Flag --cgroup-d
    Sep 01 10:40:06 ubuntu-HP-Pavilion-15-Notebook-PC kubelet[9107]: Flag --cgroup-d
    Sep 01 10:40:06 ubuntu-HP-Pavilion-15-Notebook-PC kubelet[9107]: I0901 10:40:06.
    Sep 01 10:40:06 ubuntu-HP-Pavilion-15-Notebook-PC kubelet[9107]: I0901 10:40:06.
    Sep 01 10:40:06 ubuntu-HP-Pavilion-15-Notebook-PC kubelet[9107]: I0901 10:40:06.
    Sep 01 10:40:06 ubuntu-HP-Pavilion-15-Notebook-PC kubelet[9107]: I0901 10:40:06.
    Sep 01 10:40:06 ubuntu-HP-Pavilion-15-Notebook-PC kubelet[9107]: F0901 10:40:06.
    Sep 01 10:40:06 ubuntu-HP-Pavilion-15-Notebook-PC systemd[1]: kubelet.service: M
    Sep 01 10:40:06 ubuntu-HP-Pavilion-15-Notebook-PC systemd[1]: kubelet.service: U
    Sep 01 10:40:06 ubuntu-HP-Pavilion-15-Notebook-PC systemd[1]: kubelet.service: F
    lines 788-810/810 (END)
    -- Subject: Unit kubelet.service has finished shutting down
    -- Defined-By: systemd
    -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
    -- 
    -- Unit kubelet.service has finished shutting down.
    Sep 01 10:40:05 ubuntu-HP-Pavilion-15-Notebook-PC systemd[1]: Started kubelet: The Kubernetes Node Agent.
    -- Subject: Unit kubelet.service has finished start-up
    -- Defined-By: systemd
    -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
    -- 
    -- Unit kubelet.service has finished starting up.
    -- 
    -- The start-up result is done.
    Sep 01 10:40:06 ubuntu-HP-Pavilion-15-Notebook-PC kubelet[9107]: Flag --cgroup-driver has been deprecated, This parameter should be set via the
    Sep 01 10:40:06 ubuntu-HP-Pavilion-15-Notebook-PC kubelet[9107]: Flag --cgroup-driver has been deprecated, This parameter should be set via the
    Sep 01 10:40:06 ubuntu-HP-Pavilion-15-Notebook-PC kubelet[9107]: I0901 10:40:06.117131    9107 server.go:408] Version: v1.11.2
    Sep 01 10:40:06 ubuntu-HP-Pavilion-15-Notebook-PC kubelet[9107]: I0901 10:40:06.117406    9107 plugins.go:97] No cloud provider specified.
    Sep 01 10:40:06 ubuntu-HP-Pavilion-15-Notebook-PC kubelet[9107]: I0901 10:40:06.121192    9107 certificate_store.go:131] Loading cert/key pair 
    Sep 01 10:40:06 ubuntu-HP-Pavilion-15-Notebook-PC kubelet[9107]: I0901 10:40:06.145720    9107 server.go:648] --cgroups-per-qos enabled, but --
    Sep 01 10:40:06 ubuntu-HP-Pavilion-15-Notebook-PC kubelet[9107]: F0901 10:40:06.146074    9107 server.go:262] failed to run Kubelet: Running wi
    Sep 01 10:40:06 ubuntu-HP-Pavilion-15-Notebook-PC systemd[1]: kubelet.service: Main process exited, code=exited, status=255/n/a
    Sep 01 10:40:06 ubuntu-HP-Pavilion-15-Notebook-PC systemd[1]: kubelet.service: Unit entered failed state.
    Sep 01 10:40:06 ubuntu-HP-Pavilion-15-Notebook-PC systemd[1]: kubelet.service: Failed with result 'exit-code'.
    ~
    
    
              PORTS               NAMES
    

    如有任何帮助/建议/意见,将不胜感激。

    2 回复  |  直到 6 年前
        1
  •  14
  •   Akshay Sood    6 年前

    错误已由修复

    sudo swapoff -a
    sudo sed -i '/ swap / s/^/#/' /etc/fstab
    

    重新启动计算机。

        2
  •  1
  •   Nicola Ben    6 年前

    当你使用库伯内特斯的时候 1.11.2 ,引用 CHANGELOG-1.11.md :

    kubeadm现在检测Docker cgroup驱动程序并启动kubelet 当Docker cgroup驱动程序与 由于不同的Linux发行版设置,kubelet有一套 Docker的不同cgroup驱动程序,使得启动 库贝莱。

    1. 首先检查一下你的码头工人 cfgroups

      码头工人信息| grep-i cgroup

    输出应为:

    1. 现在在您的节点上查找kubelet服务脚本,可能在 /etc/systemd/system/kubelet.service

    2. 尝试重新启动kubelet服务

    3. 再查一下库贝莱的日志( journalctl -xeu kubelet )

        3
  •  1
  •   late spring    6 年前

    sudo sed-i'/swap/s/^/#/'/etc/fstab

    我花了几天时间来解决同样的问题,这对我来说也很管用。 不知道是什么,它没有相同的效果只有'sudo swapoff-a'。

    [库贝莱检查]看起来库贝莱没有运行或健康。 http://localhost:10248/healthz '失败,错误为:Get' :拨号tcp 127.0.0.1:10248:连接:连接被拒绝。

    这些错误日志非常混乱,因为没有线索表明这个问题可能与交换配置有关。

        4
  •  0
  •   jobin at    5 年前

    如果您在openstack或任何云上运行,请确保允许安全组中的端口

    就我而言,这就是错误所在

        5
  •  0
  •   dose    5 年前

    即使已被关闭,也不应与swap一起使用 swapoff -a

    您应该在设置文件中禁用 /etc/fstab

    为了我:

    根@卡利:~#

    
    UUID=ce70d41a-0ce7-42bb-a318-d89369f93b28 / ext4 errors=remount-ro 0 1
    
    #swap was on /dev/sda5 during installation
    
    UUID=2271021b-2aed-4b49-9757-54e7d42ef33e none swap sw 0 0
    
    /dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
    

    编辑后:

    根@卡利:~#

    UUID=ce70d41a-0ce7-42bb-a318-d89369f93b28 / ext4 errors=remount-ro 0 1
    
    #swap was on /dev/sda5 during installation
    
    #UUID=2271021b-2aed-4b49-9757-54e7d42ef33e none swap sw 0 0
    
    /dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
    

    重新启动

    注: kubeadm init 通过:

    kubeadm reset

        6
  •  0
  •   bluezealot    5 年前

    我遇到了完全一样的人有问题。转身交换可以解决这个问题。 但我以另一种方式避免了它,所以我将我的解决方案张贴在这里以供参考。

    交换签入kubelet有两个阶段。

    因此,如果我们不关闭swap,kubeadm应该显示下面的消息

    [ERROR Swap]: running with swap on is not supported. Please disable swap
    

    然后它将中止init或join进程。 通过向kubeadm添加参数“--ignore preflight errors=Swap”,可以避免kubeadm检查。

    sudo kubeadm join 10.50.10.198:6443 --token XXXX.XXXXXa     --discovery-token-ca-cert-hash sha256:XX48cb7c381 --ignore-preflight-errors=Swap
    

    我们可以添加一个配置文件来避免这种情况:

     cd /etc/systemd/system/kubelet.service.d
     touch 20-allow-swap.conf
    

    [Service] 
    Environment="KUBELET_EXTRA_ARGS=--fail-swap-on=false”
    

    那么

     systemctl daemon-reload
     systemctl restart kubelet
    

    最后别忘了再次运行kubeadm join,使用“--ignore preflight errors=Swap”

    推荐文章