开发者社区 > 云原生 > 正文

kubeadm init 遇到如下问题,求教怎么解决

使用命令kubeadm init --kubernetes-version=v1.28.0 --apiserver-advertise-address=X.X.X.X(这里是真实IP,用X代替) --pod-network-cidr=10.244.0.0/16 --control-plane-endpoint=k8s-master --ignore-preflight-errors=NumCPU

报错:
[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.
^[[A^[[A^[[B
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 running Kubernetes containers by using crictl:

    - 'crictl --runtime-endpoint unix:///var/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 unix:///var/run/containerd/containerd.sock 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

用journalctl -xeu kubelet查看
12月 11 18:54:16 k8s-master kubelet[2695136]: I1211 18:54:16.886536 2695136 kubelet_node_status.go:70] "Attempting to register node" node="k8s-master"
12月 11 18:54:16 k8s-master kubelet[2695136]: E1211 18:54:16.887018 2695136 kubelet_node_status.go:92] "Unable to register node with API server" err="Post \"https://k8s-master:6443/api/v1/nodes\": dial tcp 109.105.34.101:6443: connect:>
12月 11 18:54:18 k8s-master kubelet[2695136]: E1211 18:54:18.607881 2695136 event.go:289] Unable to write event: '&v1.Event{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""}, ObjectMeta:v1.ObjectMeta{Name:"k8s-master.179fc0e6a7bb373f", Gene>
12月 11 18:54:21 k8s-master kubelet[2695136]: E1211 18:54:21.112273 2695136 eviction_manager.go:258] "Eviction manager: failed to get summary stats" err="failed to get node info: node \"k8s-master\" not found"
12月 11 18:54:23 k8s-master kubelet[2695136]: E1211 18:54:23.713382 2695136 controller.go:146] "Failed to ensure lease exists, will retry" err="Get \"https://k8s-master:6443/apis/coordination.k8s.io/v1/namespaces/kube-node-lease/leases>

展开
收起
游客zuihqdob2z5ya 2023-12-12 10:35:54 445 0
2 条回答
写回答
取消 提交回答
  • 用systemctl status kubelet命令查看,有以下问题:
    kuberuntime_manager.go:1119] "CreatePodSandbox for pod failed" err="rpc error: code = Unknown desc = failed to start sandbox container for pod \"kube-controller-manager-k8s-master\": Error response from daemon: failed to create task for container: failed to cre
    pod_workers.go:1300] "Error syncing pod, skipping" err="failed to \"CreatePodSandbox\" for \"kube-controller-manager-k8s-master_kube-system(2a4133cb3bce13c258285a67e9400fd1)\" with CreatePodSandboxError: \"Failed to create sandbox for pod \\"kube-controller-ma
    kubelet_node_status.go:70] "Attempting to register node" node="k8s-master"
    kubelet_node_status.go:92] "Unable to register node with API server" err="Post \"https://109.105.34.101:6443/api/v1/nodes\": dial tcp 109.105.34.101:6443: connect: connection refused" node="k8s-master"
    reflector.go:535] vendor/k8s.io/client-go/informers/factory.go:150: failed to list v1.Service: Get "https://109.105.34.101:6443/api/v1/services?limit=500&resourceVersion=0": dial tcp 109.105.34.101:6443: connect: connection refused
    reflector.go:147] vendor/k8s.io/client-go/informers/factory.go:150: Failed to watch
    v1.Service: failed to list *v1.Service: Get "https://109.105.34.101:6443/api/v1/services?limit=500&resourceVersion=0": dial tcp 109.105.34.101:6443: connect: connection refused
    pod_container_deletor.go:80] "Container not found in pod's containers" containerID="09525288e6053c7d56627693557429aa4f60cc7d7f9bf3f6ca295771fbf98f03"

    2023-12-13 19:11:56
    赞同 展开评论 打赏
  • 面对过去,不要迷离;面对未来,不必彷徨;活在今天,你只要把自己完全展示给别人看。

    根据您提供的错误信息,问题可能是由于kubelet没有运行或者kubelet不健康导致的。您可以尝试以下方法来解决这个问题:

    1. 检查kubelet服务是否正在运行。在终端中输入以下命令:
    systemctl status kubelet
    

    如果kubelet服务没有运行,您可以使用以下命令启动它:

    systemctl start kubelet
    
    1. 如果kubelet服务已经运行,但仍然出现错误,您可以尝试重启kubelet服务:
    systemctl restart kubelet
    
    1. 如果问题仍然存在,您可以尝试查看kubelet的日志以获取更多详细信息。在终端中输入以下命令:
    journalctl -xeu kubelet
    

    这将显示kubelet的详细日志,帮助您诊断问题。

    1. 如果以上方法都无法解决问题,您可以尝试重新安装kubeadm。首先卸载kubeadm:
    sudo apt-get remove --purge kubeadm
    

    然后重新安装kubeadm:

    sudo apt-get update
    sudo apt-get install kubeadm
    
    2023-12-12 13:05:22
    赞同 展开评论 打赏

阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载