Kubernetes delete node node and add node node

Overview

I am going to kick the zjj103 node out of the kubernetes cluster and join it again

View Node node

[root@zjj101 ~]# kubectl  get nodes
NAME     STATUS                     ROLES    AGE   VERSION
zjj101   Ready                      master   42h   v1.18.0
zjj102   Ready                      <none>   11m   v1.18.0
zjj103   Ready,SchedulingDisabled   <none>   42h   v1.18.0

Delete node

kubectl delete node [name of node]

[root@zjj101 ~]# kubectl delete node zjj103
node "zjj103" deleted

Check again which nodes are there

Found that there are only two

[root@zjj101 ~]# kubectl  get nodes
NAME     STATUS   ROLES    AGE   VERSION
zjj101   Ready    master   42h   v1.18.0
zjj102   Ready    <none>   13m   v1.18.0

Reset it on the node node

kubeadm reset command

[root@zjj103 ~]# 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

Obtain the token at the Master node

Knock kubeadm token create --print-join-command on the Master node and press Enter,

Observe the console, there will be input statements,

[root@zjj101 ~]#  kubeadm token create --print-join-command
W0228 13:55:13.351508    2655 configset.go:202] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]
kubeadm join 172.16.10.101:6443 --token 0ld7oi.jpecfi3dpxycy868     --discovery-token-ca-cert-hash sha256:13c8363f7beea0ee257730c981a501c222bc9a914c37331d07242149451f2f8f

This is the token:

​ kubeadm join 172.16.10.101:6443 --token 0ld7oi.jpecfi3dpxycy868 --discovery-token-ca-cert-hash sha256:13c8363f7beea0ee257730c981a501c222bc9a914c37331d07242149451f2f8f

Copy this token to the machine you want to join the node node and run it

Enter the token on the node node to join the kubernetes cluster

 [root@zjj103 ~]# kubeadm join 172.16.10.101:6443 --token 0ld7oi.jpecfi3dpxycy868     --discovery-token-ca-cert-hash sha256:13c8363f7beea0ee257730c981a501c222bc9a914c37331d07242149451f2f8f
W0228 13:56:26.616118   72936 join.go:346] [preflight] WARNING: JoinControlPane.controlPlane settings will be ignored when control-plane flag is not set.
[preflight] Running pre-flight checks
        [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". 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 -oyaml'
[kubelet-start] Downloading configuration for the kubelet from the "kubelet-config-1.18" ConfigMap in the kube-system namespace
[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.


View the node status on the master node

[root@zjj101 ~]# kubectl  get nodes
NAME     STATUS   ROLES    AGE   VERSION
zjj101   Ready    master   42h   v1.18.0
zjj102   Ready    <none>   17m   v1.18.0
zjj103   Ready    <none>   61s   v1.18.0

Guess you like

Origin blog.csdn.net/qq_41489540/article/details/114220895