节点执行kubeadm join加入k8s集群时,报错:

[root@k8s-node-01 ~]# kubeadm join k8s-master:6443 --token 80fefr.8i5fxrhz74pewyyy --discovery-token-ca-cert-hash sha256:abc768bc01ae0c4c384ac0983f3637d3f24a9c148e79f03a6f3bf26c0c809d4d --control-plane
[preflight] Running pre-flight checks



error execution phase preflight: couldn't validate the identity of the API Server: could not find a JWS signature in the cluster-info ConfigMap for token ID "80fefr"
[root@k8s-node-01 pki]# kubeadm join k8s-master:6443 --token 80fefr.8i5fxrhz74pewyyy --discovery-token-ca-cert-hash sha256                                      :abc768bc01ae0c4c384ac0983f3637d3f24a9c148e79f03a6f3bf26c0c809d4d --control-plane
[preflight] Running pre-flight checks
        [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "system                                      d". 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 etcd CA: couldn't load the certificate file /etc/kubernetes/pki/etcd/ca.crt: open /etc/kub                                      ernetes/pki/etcd/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

这两个异常提示,需要将k8s主节点的相关文件 拷贝到 执行kubeadm join的节点主机上,可以使用scp命令(原作者处理方案地址:https://www.freesion.com/article/52781320627/

#在k8s主节点上执行命令,拷贝相关证书文件、配置文件 至节点主机上
scp /etc/kubernetes/pki/ca.* root@192.168.202.7:/etc/kubernetes/pki/
scp /etc/kubernetes/pki/sa.* root@192.168.202.7:/etc/kubernetes/pki/
scp /etc/kubernetes/pki/front-proxy-ca.* root@192.168.202.7:/etc/kubernetes/pki/
scp /etc/kubernetes/pki/etcd/ca.* root@192.168.202.7:/etc/kubernetes/pki/etcd/
scp /etc/kubernetes/admin.conf root@192.168.202.7:/etc/kubernetes/

然后重新执行kubeadm join 执行成功:
 


[root@k8s-node-01 ~]# kubeadm join k8s-master:6443 --token 80fefr.8i5fxrhz74pewyyy --discovery-token-ca-cert-hash sha256:abc768bc01ae0c4c384ac0983f3637d3f24a9c1                                                                     48e79f03a6f3bf26c0c809d4d --control-plane
[preflight] Running pre-flight checks
[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'
[preflight] Running pre-flight checks before initializing the new control plane instance
[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 "apiserver-etcd-client" certificate and key
[certs] Generating "etcd/healthcheck-client" certificate and key
[certs] Generating "etcd/peer" certificate and key
[certs] etcd/peer serving cert is signed for DNS names [k8s-node-01 localhost] and IPs [192.168.202.7 127.0.0.1 ::1]
[certs] Generating "etcd/server" certificate and key
[certs] etcd/server serving cert is signed for DNS names [k8s-node-01 localhost] and IPs [192.168.202.7 127.0.0.1 ::1]
[certs] Generating "apiserver" certificate and key
[certs] apiserver serving cert is signed for DNS names [k8s-master k8s-node-01 kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.clust                                                                     er.local] and IPs [10.96.0.1 192.168.202.7]
[certs] Generating "apiserver-kubelet-client" certificate and key
[certs] Generating "front-proxy-client" certificate and key
[certs] Valid certificates and keys now exist in "/etc/kubernetes/pki"
[certs] Using the existing "sa" key
[kubeconfig] Generating kubeconfig files
[kubeconfig] Using kubeconfig folder "/etc/kubernetes"
[kubeconfig] Using existing kubeconfig file: "/etc/kubernetes/admin.conf"
[kubeconfig] Writing "controller-manager.conf" kubeconfig file
[kubeconfig] Writing "scheduler.conf" kubeconfig file
[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"
[check-etcd] Checking that the etcd cluster is healthy
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Starting the kubelet
[kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap...
[etcd] Announced new etcd member joining to the existing etcd cluster
[etcd] Creating static Pod manifest for "etcd"
[etcd] Waiting for the new etcd member to join the cluster. This can take up to 40s
[upload-config] Storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace
[mark-control-plane] Marking the node k8s-node-01 as control-plane by adding the labels "node-role.kubernetes.io/master=''" and "node-role.kubernetes.io/control                                                                     -plane='' (deprecated)"
[mark-control-plane] Marking the node k8s-node-01 as control-plane by adding the taints [node-role.kubernetes.io/master:NoSchedule]

This node has joined the cluster and a new control plane instance was created:

* Certificate signing request was sent to apiserver and approval was received.
* The Kubelet was informed of the new secure connection details.
* Control plane (master) label and taint were applied to the new node.
* The Kubernetes control plane instances scaled up.
* A new etcd member was added to the local/stacked etcd cluster.

To start administering your cluster from this node, you need to run the following as a regular user:

        mkdir -p $HOME/.kube
        sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
        sudo chown $(id -u):$(id -g) $HOME/.kube/config

Run 'kubectl get nodes' to see this node join the cluster.

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐