K8s集群初始化报错 [kubelet-check] The HTTP call equal to ‘curl -sSL http://localhost:10248/healthz‘

简介

安装K8s时,在集群及节点初始化过程中出现[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.报错。

处理步骤

#在安装K8s初始化主节点过程中,出现如下报错:
queena@queena-Lenovo:~$ sudo kubeadm init --apiserver-advertise-address=192.168.31.245 --pod-network-cidr=10.244.0.0/16  --kubernetes-version=v1.22.3
[init] Using Kubernetes version: v1.22.3
[preflight] Running pre-flight checks
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
[certs] Using certificateDir folder "/etc/kubernetes/pki"
[certs] Generating "ca" certificate and key
[certs] Generating "apiserver" certificate and key
[certs] apiserver serving cert is signed for DNS names [kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local queena-lenovo] and IPs [10.96.0.1 192.168.31.245]
[certs] Generating "apiserver-kubelet-client" certificate and key
[certs] Generating "front-proxy-ca" certificate and key
[certs] Generating "front-proxy-client" certificate and key
[certs] Generating "etcd/ca" certificate and key
[certs] Generating "etcd/server" certificate and key
[certs] etcd/server serving cert is signed for DNS names [localhost queena-lenovo] and IPs [192.168.31.245 127.0.0.1 ::1]
[certs] Generating "etcd/peer" certificate and key
[certs] etcd/peer serving cert is signed for DNS names [localhost queena-lenovo] and IPs [192.168.31.245 127.0.0.1 ::1]
[certs] Generating "etcd/healthcheck-client" certificate and key
[certs] Generating "apiserver-etcd-client" certificate and key
[certs] Generating "sa" key and public key
[kubeconfig] Using kubeconfig folder "/etc/kubernetes"
[kubeconfig] Writing "admin.conf" kubeconfig file
[kubeconfig] Writing "kubelet.conf" kubeconfig file
[kubeconfig] Writing "controller-manager.conf" kubeconfig file
[kubeconfig] Writing "scheduler.conf" kubeconfig file
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Starting the kubelet
[control-plane] Using manifest folder "/etc/kubernetes/manifests"
[control-plane] Creating static Pod manifest for "kube-apiserver"
[control-plane] Creating static Pod manifest for "kube-controller-manager"
[control-plane] Creating static Pod manifest for "kube-scheduler"
[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"
[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s
[kubelet-check] Initial timeout of 40s passed.
[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)

	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.

	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'

error execution phase wait-control-plane: couldn't initialize a Kubernetes cluster
To see the stack trace of this error execute with --v=5 or higher

查看docker驱动是否与kubelet驱动一致即可

docker info | grep Cgroup
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
WARNING: No swap limit support

#查看kubelet驱动.
$ sudo cat /var/lib/kubelet/config.yaml | grep cgroup
cgroupDriver: systemd

#修改docker驱动,查看/etc/docker/daemon.json文件,没有的话,手动创建,添加以下内容:
$ vim /etc/docker/daemon.json
#在该文件中加入,   "exec-opts": ["native.cgroupdriver=systemd"]
{
  "registry-mirrors": ["https://dpxn2pal.mirror.aliyuncs.com"],
  "exec-opts": [ "native.cgroupdriver=systemd" ]
}

#重启docker 
$ systemctl daemon-reload
$ systemctl restart docker
#重启kubelet
$ systemctl restart kubelet
$ sudo kubeadm reset  #此处重置,没关系,反正原来的也起不来.

#下面这两行用来验证cgroupdriver 修改生效,都得出systemd.
$ docker info -f {{.CgroupDriver}}
systemd
$ docker info | grep -i cgroup
 Cgroup Driver: systemd
 Cgroup Version: 1
WARNING: No swap limit support

再次执行K8s初始化主节点,即可成功.

K8s集群初始化报错 [kubelet-check] The HTTP call equal to ‘curl -sSL http://localhost:10248/healthz‘

原创文章,作者:AIRF,如若转载,请注明出处:http://www.ai-rf.com/index.php/2023/09/16/k8s%e9%9b%86%e7%be%a4%e5%88%9d%e5%a7%8b%e5%8c%96%e6%8a%a5%e9%94%99-kubelet-check-the-http-call-equal-to-curl-ssl-http-localhost10248-healthz/

(0)
AIRFAIRF
上一篇 2023年9月15日
下一篇 2023年9月17日

相关推荐

  • 容器升级内核及重启后遇到的问题

    前景描述 公司10台物理服务器,系统为Redhat7.9,因安装K8S,需将内核升级至3.10.0-1060以上,并修改相关参数,否则会造成内存泄露问题。 操作步骤 需要用到的升级…

    ChatGPT 2022年7月9日
  • K8S一键搭建集群脚本

    #!/bin/bash # Author: Nuoyo # mail:2469329338@qq.com RED=”33[31m” # Error message GREEN=”3…

    2023年9月17日
  • 【二】快速搭建卸载K8S集群

    准备工作 需要Linux CentOS 7.x 两台及以上,本文用的 7.9。 Master最低配置2C2G 安装步骤多个节点可以并行操作,默认所有操作各节点都要执行,某些操作仅主…

    2023年9月17日
  • K8S搭建DashBoard可视化面板

    kubernetes中管理集群中资源的方式通常有四种:命令行、YAML、API和图形界面。其中dashboard是K8s官方的图形界面工具。使用简单,操作方便,能监控node和po…

    2023年9月17日
  • docker容器分配指定内存和cpu

    如何给分配内存和cpu?默认情况下,容器使用的资源是不受限制的。也就是可以使用主机内核调度器所允许的最大资源。但是在容器的使用过程中,经常需要对容器可以使用的主机资源进行限制,下面…

    ChatGPT 2023年8月14日
  • Kubernetets-Cka考试题库

    本次测试的所有问题都必须在指定的cluster配置环境中完成。为尽量减少切换,系统已对问题进行分组,同一cluster内的所有问题将连续显示。 开启TAB补全 做题前先配置k8s自…

    ChatGPT 2022年2月18日
  • 通过Docker创建CentOS系统容器的步骤

    前言 先安装Docker,使用文内的脚本可以快速创建CentOS 7.8虚拟系统集群,并通过SSH(Secure Shell)远程工具连接。 创建桥接网络,方便容器间通信 指令格式…

    ChatGPT 2022年12月4日
  • k8s集群关机后,如何解决 kubernetes 重启起不来的问题

    前景介绍 使用本地vmware搭建集群后,直接把vmware关机,然后再次启动后提示集群异常,所有容器状态为exited,并报错 The connection to the ser…

    2023年9月17日
  • 【六】K8S_Ingress | Service的统一网关入口

    Ingress简介 在Kubernetes(K8S)中,Ingress的主要用途是管理和暴露集群中的HTTP和HTTPS服务。它充当了从集群外部流量到集群内部服务的入口,并提供了一…

    2023年9月17日
  • Docker基础命令(常用的docker命令)

    镜像相关命令 搜索镜像 # 从网络上查找需要的镜像 docker search 镜像名称 docker 搜索镜像 拉取镜像 # 从Docker的仓库下载镜像到本地,镜像名称格式为名…

    ChatGPT 2022年11月28日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注