【问题标题】:Node cannot join cluster K8S onprem节点无法加入集群 K8S onprem
【发布时间】:2021-01-06 00:42:12
【问题描述】:

我正在尝试通过 VMS 设置 K8S 并成功安装主节点。

kubectl get nodes -o wide
master   Ready    control-plane,master   14m   v1.20.1   192.168.5.13   <none>        Ubuntu 18.04.5 LTS   4.15.0-124-generic   docker://18.6.3

并且worker节点也准备安装ocker、kubeadm、kubectl和kubelet。防火墙已禁用,master 和 worker 上的交换也已关闭。

当我尝试在 worker 上以 root 身份运行时:

kubeadm join 192.168.5.13:6443 --token pk2b8n.i89ywir9vs7cqm7n     --discovery-token-ca-cert-hash sha256:e9214f892d58196fa6608968f82965113e5dc1928c00d7cf066b52ae4d7037f0     --control-plane

得到下面的错误

[preflight] Running pre-flight checks
    [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
[preflight] Reading configuration from the cluster...
[preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
error execution phase preflight: 
One or more conditions for hosting a new control plane instance is not satisfied.

failure loading certificate for CA: couldn't load the certificate file /etc/kubernetes/pki/ca.crt: open /etc/kubernetes/pki/ca.crt: no such file or directory

Please ensure that:
* The cluster has a stable controlPlaneEndpoint address.
* The certificates that must be shared among control plane instances are provided.


To see the stack trace of this error execute with --v=5 or higher

我无法处理它。有什么帮助吗?我会很感激的。

【问题讨论】:

    标签: kubernetes


    【解决方案1】:

    花了很多时间才发现,希望对大家有所帮助!

    vagrant@master:~$ kubeadm token create --print-join-command
    
    kubeadm join 192.168.33.13:6443 --token 7vz9ab.uf2o74um8sqfncv1     --discovery-token-ca-cert-hash sha256:e9214f892d58196fa6608968f82965113e5dc1928c00d7cf066b52ae4d7037f0 
    

    现在转到工作节点并以 root 身份再次运行此命令

    root@worker:/ kubeadm join 192.168.33.13:6443 --token 7vz9ab.uf2o74um8sqfncv1     --discovery-token-ca-cert-hash sha256:e9214f892d58196fa6608968f82965113e5dc1928c00d7cf066b52ae4d7037f0 
    

    在master上,你可以验证

    vagrant@master:~$ kubectl get nodes
    NAME       STATUS     ROLES                  AGE   VERSION
    master     Ready      control-plane,master   32m   v1.20.1
    worker-1   NotReady   <none>                 10s   v1.20.1
    

    【讨论】:

    • 请将您的答案标记为已接受。它不会给你积分,但它会在社区中更加明显。
    • @PjoterS 我可以在 48 小时后标记它。我会尽快的。
    • 所以,这里发生的情况是,由于 --control-plane 标志,您尝试加入新的主 (HA),当您删除它时,它按预期工作正常。
    猜你喜欢
    • 1970-01-01
    • 2019-01-15
    • 2016-12-14
    • 2020-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-29
    相关资源
    最近更新 更多