使用kubeadm创建集群失败报Unable to register node with API server

环境

  • containerd 1.6.4
  • k8s 1.24.1(1.23.5)

错误现象


	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 cri-o/containerd using crictl:
		- 'crictl --runtime-endpoint /run/containerd/containerd.sock ps -a | grep kube | grep -v pause'
		Once you have found the failing container, you can inspect its logs with:
		- 'crictl --runtime-endpoint /run/containerd/containerd.sock logs CONTAINERID'

couldn't initialize a Kubernetes cluster
k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/init.runWaitControlPlanePhase

日志分析

根据提示使用journalctl -xeu kubelet 查看日志,日志文件中的错误主要有四种:

  1. 找不到节点
Error getting node" err="node \"k8s-master\" not found
  1. Unable to register node with API server
  2. 获取不到pause镜像
May 31 09:04:45 k8s-master kubelet[12906]: E0531 09:04:45.363423   12906 remote_runtime.go:198] "RunPodSandbox from runtime service failed" err="rpc error: code = Unknown desc = failed to get sandbox image \"k8s.gcr.io/pause:3.6\": failed to pull image \"k8s.gcr.io/pause:3.6\": failed to pull and unpack image \"k8s.gcr.io/pause:3.6\": failed to resolve reference \
  • 9
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
Kubernetes是一款强大的容器编排和管理工具,可以快速部署和管理容器化应用程序。在本文中,我们将演示如何使用kubeadm部署Kubernetes集群。 1. 安装Docker和kubeadm 在所有Kubernetes节点上安装Docker和kubeadm。在Ubuntu上,可以使用以下命令: ``` sudo apt-get update sudo apt-get install docker.io sudo systemctl enable docker sudo systemctl start docker sudo apt-get install -y apt-transport-https curl curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list deb https://apt.kubernetes.io/ kubernetes-xenial main EOF sudo apt-get update sudo apt-get install -y kubelet kubeadm kubectl sudo apt-mark hold kubelet kubeadm kubectl ``` 2. 初始化master节点 在其中一个节点上,使用kubeadm初始化Kubernetes master节点: ``` sudo kubeadm init --pod-network-cidr=10.244.0.0/16 ``` 此命令会在当前节点上启动Kubernetes master,并输出一些配置信息。请注意,您需要将此信息保存在某个地方,因为您稍后需要在其他节点上加入集群使用它们。 3. 安装网络插件 Kubernetes需要网络插件才能在Pod之间建立网络通信。在本教程中,我们将使用Flannel作为网络插件。在master节点上,使用以下命令安装Flannel: ``` kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml ``` 4. 加入worker节点 在所有worker节点上,使用kubeadm命令加入Kubernetes集群: ``` sudo kubeadm join <master-node-ip>:<master-node-port> --token <token> --discovery-token-ca-cert-hash sha256:<hash> ``` 其中,`<master-node-ip>`和`<master-node-port>`是您在步骤2中保存的master节点的IP地址和端口号。`<token>`和`<hash>`是在kubeadm init命令输出的`kubeadm join`命令中生成的令牌和散列值。 5. 验证集群 在master节点上,使用以下命令验证Kubernetes集群: ``` kubectl get nodes ``` 此命令应显示所有加入集群的节点。 恭喜,您已成功使用kubeadm部署了Kubernetes集群!现在您可以使用Kubernetes来部署和管理容器化应用程序。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值