解决node加入集群时token过期的问题

1)问题:当work node加入k8s集群时出现类似如下错误时“You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'
unable to fetch the kubeadm-config ConfigMap: failed to get config map: Unauthorized”。完整的提示可能类似如下所示:

root@ubuntu1804-k8-s5:~# kubeadm join 10.30.28.230:8443 --token x5h1nq.v922xzw40l6y2h3u --discovery-token-ca-cert-hash sha256:76b907a90281adbda66a40ac37c06ea864e89c960a49679bc698f3642fd05a51
[preflight] Running pre-flight checks
    [WARNING SystemVerification]: this Docker version is not on the list of validated versions: 18.09.2. Latest validated version: 18.06
[discovery] Trying to connect to API Server "10.30.28.230:8443"
[discovery] Created cluster-info discovery client, requesting info from "https://10.30.28.230:8443"
[discovery] Requesting info from "https://10.30.28.230:8443" again to validate TLS against the pinned public key
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server "10.30.28.230:8443"
[discovery] Successfully established connection with API Server "10.30.28.230:8443"
[join] Reading configuration from the cluster...
[join] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'
unable to fetch the kubeadm-config ConfigMap: failed to get config map: Unauthorized

2)解决方法

原因可能是token过期了,可以采用如下命令创建新的token

kubeadm token create

解决node加入集群时token过期的问题_第1张图片

然后用新的token执行类似如下命令即可加入集群成功:

kubeadm join 10.30.28.230:8443 --token lnq4mk.ow6ldfelkuv0mpnx --discovery-token-ca-cert-hash sha256:76b907a90281adbda66a40ac37c06ea864e89c960a49679bc698f3642fd05a51

你可能感兴趣的:(K8S)