Kubernetes删除node节点再添加node节点

概述

我准备把zjj103节点从kubernetes集群踢出去,然后再加入进来

查看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

删除节点

kubectl delete node [节点的名字]

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

再次查看有哪些节点

发现只有两个了

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

在node节点重置一下

kubeadm reset 命令

[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

在Master节点获取token

在Master节点敲 kubeadm token create --print-join-command 然后回车,

观察控制台 ,会有输入语句,

[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

这个就是token:

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

把这个token复制到你要加入node节点的机器上运行一下

在node节点输入token加入到kubernetes集群

 [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.


在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

猜你喜欢

转载自blog.csdn.net/qq_41489540/article/details/114220895