编程语言
首页 > 编程语言> > k8s集群-master和node节点添加与删除、kubenetes之master节点升级、高可用

k8s集群-master和node节点添加与删除、kubenetes之master节点升级、高可用

作者:互联网

master1 192.168.181.110 4C  4G
master2

192.168.181.111

4C  4G
master3 192.168.181.112 4C  4G
node1 192.168.181.130 4C  4G
node2 192.168.181.131 4C  4G
node3 192.168.181.132 4C  4G
etcd1 192.168.181.140 2C  2G
etcd2 192.168.181.141 2C  2G
etcd3 192.168.181.142 2C  2G
haproxy1 192.168.181.101

2C  1G

haproxy2 192.168.181.102 2C  1G

 

 

 

 

 

 

 

 

 

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,master1,service,192.168,master,kube,root,节点
来源: https://www.cnblogs.com/cndr/p/15958006.html