2021-01-19 17:41:00 +08:00
|
|
|
|
# 管理 kube_master 节点
|
2018-03-09 22:02:55 +08:00
|
|
|
|
|
2021-01-19 17:41:00 +08:00
|
|
|
|
## 1.增加 kube_master 节点
|
2018-03-09 22:02:55 +08:00
|
|
|
|
|
2021-02-01 23:09:59 +08:00
|
|
|
|
新增`kube_master`节点大致流程为:(参考ezctl 中add-master函数和playbooks/23.addmaster.yml)
|
2019-02-27 10:53:02 +08:00
|
|
|
|
- [可选]新节点安装 chrony 时间同步
|
2018-03-18 22:51:05 +08:00
|
|
|
|
- 新节点预处理 prepare
|
2022-06-05 19:34:53 +08:00
|
|
|
|
- 新节点安装 container runtime
|
2021-01-19 17:41:00 +08:00
|
|
|
|
- 新节点安装 kube_master 服务
|
|
|
|
|
- 新节点安装 kube_node 服务
|
2018-03-18 22:51:05 +08:00
|
|
|
|
- 新节点安装网络插件相关
|
|
|
|
|
- 禁止业务 pod调度到新master节点
|
2019-06-08 23:07:39 +08:00
|
|
|
|
- 更新 node 节点 haproxy 负载均衡并重启
|
2018-03-09 22:02:55 +08:00
|
|
|
|
|
|
|
|
|
### 操作步骤
|
|
|
|
|
|
2022-06-05 19:34:53 +08:00
|
|
|
|
执行如下 (假设待增加节点为 192.168.1.11, 集群名称test-k8s):
|
2018-03-09 22:02:55 +08:00
|
|
|
|
|
|
|
|
|
``` bash
|
2022-06-05 19:34:53 +08:00
|
|
|
|
# ssh 免密码登录
|
|
|
|
|
$ ssh-copy-id 192.168.1.11
|
|
|
|
|
|
|
|
|
|
# 新增节点
|
2021-02-01 23:09:59 +08:00
|
|
|
|
$ ezctl add-master test-k8s 192.168.1.11
|
2023-01-26 10:21:55 +08:00
|
|
|
|
|
|
|
|
|
# 同理,重复上面步骤再新增节点并自定义nodename
|
|
|
|
|
$ ezctl add-master test-k8s 192.168.1.12 k8s_nodename=master-03
|
2018-03-09 22:02:55 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 验证
|
|
|
|
|
|
|
|
|
|
``` bash
|
|
|
|
|
# 在新节点master 服务状态
|
|
|
|
|
$ systemctl status kube-apiserver
|
|
|
|
|
$ systemctl status kube-controller-manager
|
|
|
|
|
$ systemctl status kube-scheduler
|
|
|
|
|
|
|
|
|
|
# 查看新master的服务日志
|
|
|
|
|
$ journalctl -u kube-apiserver -f
|
|
|
|
|
|
2018-03-18 22:51:05 +08:00
|
|
|
|
# 查看集群节点,可以看到新 master节点 Ready, 并且禁止了POD 调度功能
|
|
|
|
|
$ kubectl get node
|
|
|
|
|
NAME STATUS ROLES AGE VERSION
|
|
|
|
|
192.168.1.1 Ready,SchedulingDisabled <none> 3h v1.9.3
|
|
|
|
|
192.168.1.2 Ready,SchedulingDisabled <none> 3h v1.9.3
|
|
|
|
|
192.168.1.3 Ready <none> 3h v1.9.3
|
|
|
|
|
192.168.1.4 Ready <none> 3h v1.9.3
|
2019-02-27 10:53:02 +08:00
|
|
|
|
192.168.1.11 Ready,SchedulingDisabled <none> 2h v1.9.3 # 新增 master节点
|
2018-03-09 22:02:55 +08:00
|
|
|
|
```
|
2018-03-18 22:51:05 +08:00
|
|
|
|
|
2021-01-19 17:41:00 +08:00
|
|
|
|
## 2.删除 kube_master 节点
|
2019-06-08 23:07:39 +08:00
|
|
|
|
|
|
|
|
|
|
2021-02-01 23:09:59 +08:00
|
|
|
|
删除`kube_master`节点大致流程为:(参考ezctl 中del-master函数和playbooks/33.delmaster.yml)
|
2019-06-08 23:07:39 +08:00
|
|
|
|
- 检测是否可以删除
|
|
|
|
|
- 迁移节点 pod
|
|
|
|
|
- 删除 master 相关服务及文件
|
|
|
|
|
- 删除 node 相关服务及文件
|
|
|
|
|
- 从集群删除 node 节点
|
|
|
|
|
- 从 ansible hosts 移除节点
|
|
|
|
|
- 在 ansible 控制端更新 kubeconfig
|
|
|
|
|
- 更新 node 节点 haproxy 配置
|
|
|
|
|
|
|
|
|
|
### 操作步骤
|
|
|
|
|
|
|
|
|
|
``` bash
|
2021-02-01 23:09:59 +08:00
|
|
|
|
$ ezctl del-master test-k8s 192.168.1.11 # 假设待删除节点 192.168.1.11
|
2019-06-08 23:07:39 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 验证
|
|
|
|
|
|
|
|
|
|
略
|
|
|
|
|
|