k8s集群中,有时候发现有些节点状态为 NotReady,如何修复为Ready状态呢?

[root@k8s-master~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION k8s-master Ready master 4d8h v1.14.1 k8s-node1 NotReady <none> 4d8h v1.14.1 k8s-node2 Ready <none> 4d8h v1.14.1

 

1.重新生成新的token
默认token的有效期为24小时,当过期之后,该token就不可用了,在master节点上执行 kubeadm token create
 
$ kubeadm token create
c9afga.w3fue0yh3gzxczic

查看token

$ kubeadm token list
TOKEN                     TTL       EXPIRES                     USAGES                   DESCRIPTION   EXTRA GROUPS
c9afga.w3fue0yh3gzxczic   23h       2019-07-26T14:30:54+08:00   authentication,signing   <none>        system:bootstrappers:kubeadm:default-node-token

  

 
2.获取ca证书sha256编码hash值

$ openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
8b79b6461e58c07333cb2851fe74fd4374af8bbbe0bf7e040b415b86ad4fb89d

 

 
3.节点加入集群
 先清理环境,然后再kubeadm join (Node节点上执行)
$ kubeadm reset

$ kubeadm join 192.168.38.11:6443 --token c9afga.w3fue0yh3gzxczic \
    --discovery-token-ca-cert-hash sha256:8b79b6461e58c07333cb2851fe74fd4374af8bbbe0bf7e040b415b86ad4fb89d
 
 4.再次查看
 
[root@k8s-master~]# kubectl get nodes
NAME         STATUS   ROLES    AGE    VERSION
k8s-master   Ready    master   4d8h   v1.14.1
k8s-node1    Ready    <none>   4d8h   v1.14.1
k8s-node2    Ready    <none>   4d8h   v1.14.1

  

 

转载于:https://www.cnblogs.com/caoxb/p/11244094.html

Logo

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

更多推荐