k8s集群-master和node节点添加与删除、kubenetes集群版本升级
kubeasz工具增删master与node
添加mater节点
当前节点
[root@master1 kubeasz]# ./ezctl add-master k8s-cluster1 192.168.181.112
集群名称 新增的masterIP
增加node节点
[root@master1 kubeasz]# ./ezctl add-node k8s-cluster1 192.168.181.142
删除node节点
[root@master1 kubeasz]# ./ezctl del-node k8s-cluster1 192.168.181.142
查看节点信息
手动删除matser与node节点
先驱逐,再删除node
手动强制驱逐node节点
[root@master1 kubeasz]# kubectl drain 192.168.181.142 --ignore-daemonsets --delete-emptydir-data
忽略数据 日志、临时文件删除
[root@master1 kubeasz]# kubectl delete node 192.168.181.142
集群升级
haproxy配置文件,升级节点前先暂停数据往该升级节点写入,因此注释需要升级的节点配置
[root@ha1 ~]# systemctl reload haproxy.service
暂停master3的服务
[root@master3 ~]#systemctl stop kube-apiserver.service kube-controller-manager kubelet kube-proxy.service kube-scheduler.service
每个node节点都要执行
[root@node2 ~]# vim /etc/kube-lb/conf/kube-lb.conf
[root@node2 ~]# systemctl restart kubee--lb
master1上的新版本的二进制包拷贝到master3,替换master3 /usr/bin里的文件
[root@master1 bin]# scp -r kube-apiserver kube-controller-manager kubectl kubelet kube-scheduler 192.168.181.112:/usr/bin/
拷贝完后启动master3的服务
[root@master3 ~]# systemctl start kube-apiserver.service kube-controller-manager kubelet kube-proxy.service kube-scheduler.service
master3升级成功
master1和master2同理,暂停服务
[root@master1 ~]##systemctl stop kube-apiserver.service kube-controller-manager kubelet kube-proxy.service kube-scheduler.service
[root@master2 ~]# systemctl stop kube-apiserver.service kube-controller-manager kubelet kube-proxy.service kube-scheduler.service
haroxy配置文件注释
[root@ha1 ~]# systemctl reload haproxy.service
所有node节点执行
[root@node2 ~]# vim /etc/kube-lb/conf/kube-lb.conf
[root@node2 ~]# systemctl restart kubee--lb
拷贝新版本的二进制文件到master1和master的/usr/bin
启动服务
[root@master1 ~]# systemctl start kube-apiserver.service kube-controller-manager kubelet kube-proxy.service kube-scheduler.service
[root@master2 ~]# systemctl start kube-apiserver.service kube-controller-manager kubelet kube-proxy.service kube-scheduler.service
所有master节点由v1.22.2版本升级到v1.22.5
负载均衡器配置文件去掉之前的注释
[root@ha1 ~]# systemctl reload haproxy.service
至此master节点升级完成
node节点和kube-proxy升级
[root@node1 ~]# systemctl stop kubectl kubele kube-proxy
[root@node2 ~]# systemctl stop kubectl kubele kube-proxy
[root@node3 ~]# systemctl stop kubectl kubele kube-proxy
master1
#cd /usr/bin
[root@master1 bin]# scp -r kubelet kubectl kube-proxy 192.168.181.140:/usr/bin/
[root@master1 bin]# scp -r kubelet kubectl kube-proxy 192.168.181.141:/usr/bin/
[root@master1 bin]# scp -r kubelet kubectl kube-proxy 192.168.181.142:/usr/bin/
node节点
[root@node1 ~]# systemctl start kubelet kube-proxy.service
[root@node2 ~]# systemctl start kubelet kube-proxy.service
[root@node3 ~]# systemctl start kubelet kube-proxy.service
升级完成