当我修改某个node的hostname后, k8s就显示这个node状态时not ready了
这时只能删除和重新加入这个node(新的node 里面并没有部署任何pod)
gateman@k8smaster:~$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
admeuc-vm1 NotReady <none> 202d v1.22.15
amdeuc-vm2 Ready <none> 195d v1.22.15
amdeuc-vm3 Ready <none> 195d v1.22.15
k8smaster Ready control-plane,master 238d v1.22.15
k8snode0 Ready <none> 238d v1.22.15
步骤1 在master node上删除这个节点node
gateman@k8smaster:~$ kubectl delete node admeuc-vm1
node "admeuc-vm1" deleted
步骤2 在master node上print出加入master node的命令
gateman@k8smaster:~$ sudo kubeadm token create --print-join-command
[sudo] password for gateman:
kubeadm join 10.0.1.152:6443 --token 66cw1l.a4e7bjm5l4huq6tf --discovery-token-ca-cert-hash sha256:d0ca4eb129c624b324934398e78009f73ca16bae228ad2f2bc0056294533b46b
步骤3 在节点node上 reset
gateman@amdeuc-vm1:~$ sudo kubeadm reset
[reset] WARNING: Changes made to this host by 'kubeadm init' or 'kubeadm join' will be reverted.
[reset] Are you sure you want to proceed? [y/N]: y
[preflight] Running pre-flight checks
W0617 16:13:48.239267 2411 removeetcdmember.go:80] [reset] No kubeadm config, using etcd pod spec to get data directory
[reset] No etcd config found. Assuming external etcd
[reset] Please, manually reset etcd to prevent further issues
[reset] Stopping the kubelet service
[reset] Unmounting mounted directories in "/var/lib/kubelet"
[reset] Deleting contents of config directories: [/etc/kubernetes/manifests /etc/kubernetes/pki]
[reset] Deleting files: [/etc/kubernetes/admin.conf /etc/kubernetes/kubelet.conf /etc/kubernetes/bootstrap-kubelet.conf /etc/kubernetes/controller-manager.conf /etc/kubernetes/scheduler.conf]
[reset] Deleting contents of stateful directories: [/var/lib/kubelet /var/lib/dockershim /var/run/kubernetes /var/lib/cni]
The reset process does not clean CNI configuration. To do so, you must remove /etc/cni/net.d
The reset process does not reset or clean up iptables rules or IPVS tables.
If you wish to reset iptables, you must do so manually by using the "iptables" command.
If your cluster was setup to utilize IPVS, run ipvsadm --clear (or similar)
to reset your system's IPVS tables.
The reset process does not clean your kubeconfig files and you must remove them manually.
Please, check the contents of the $HOME/.kube/config file.
步骤4 在节点node上 再次加入master node
gateman@amdeuc-vm1:~$ sudo kubeadm join 10.0.1.152:6443 --token 66cw1l.a4e7bjm5l4huq6tf --discovery-token-ca-cert-hash sha256:d0ca4eb129c624b324934398e78009f73ca16bae228ad2f2bc0056294533b46b
[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.
这时应该ok了
重新检查nodes的状态, 已经ready!
gateman@k8smaster:~$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
amdeuc-vm1 Ready <none> 6s v1.22.15
amdeuc-vm2 Ready <none> 195d v1.22.15
amdeuc-vm3 Ready <none> 195d v1.22.15
k8smaster Ready control-plane,master 238d v1.22.15
k8snode0 Ready <none> 238d v1.22.15