Kubernetes集群添加node报错:certificate has expired or is not yet valid
  aOYB9Qh7rxCg 2023年11月02日 76 0

Kubernetes集群添加node报错:

[root@k8s-node1 manifests]# kubeadm join 10.10.10.185:6443 --token r04efh.mydlquml0w7790fu --discovery-token-ca-cert-hash sha256:fc7812c051080ea200b23ef1e96312f58df2c17a2323f1b5434545fe49024a7a
[preflight] Running pre-flight checks
error execution phase preflight: couldn't validate the identity of the API Server: Get "https://10.10.10.185:6443/api/v1/namespaces/kube-public/configmaps/cluster-info?timeout=10s": tls: failed to verify certificate: x509: certificate has expired or is not yet valid: current time 2023-09-25T13:40:49+08:00 is before 2023-09-25T06:46:41Z
To see the stack trace of this error execute with --v=5 or higher

检查发现是由于时钟不同步导致。 解决方法十分简单:配置所有主机时钟同步即可。完成后,重新执行以下步骤,注册成功:

  1. 在master重新生成token
[root@k8s-master opt]# kubeadm token generate
aai0oy.12s7vy9fmp4uv2qs
  1. 生成join命令行
[root@k8s-master opt]# kubeadm token create aai0oy.12s7vy9fmp4uv2qs --print-join-command --ttl=0
kubeadm join 10.10.10.185:6443 --token aai0oy.12s7vy9fmp4uv2qs --discovery-token-ca-cert-hash sha256:fc7812c051080ea200b23ef1e96312f58df2c17a2323f1b5434545fe49024a7a
  1. 在node主机上执行命令行
[root@k8s-node1 manifests]# kubeadm join 10.10.10.185:6443 --token aai0oy.12s7vy9fmp4uv2qs --discovery-token-ca-cert-hash sha256:fc7812c051080ea200b23ef1e96312f58df2c17a2323f1b5434545fe49024a7a
[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'
[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...

This node has joined the cluster:
* Certificate signing request was sent to apiserver and a response was received.
* The Kubelet was informed of the new secure connection details.

Run 'kubectl get nodes' on the control-plane to see this node join the cluster.
【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
aOYB9Qh7rxCg