二進制部署K8s集羣第24節平滑切換版本技巧

1、K8s平滑切換版本技巧

1.1 升級方法

二進制部署K8s集羣第23節addons之安裝部署dashboard

1 一臺服務器操做完成切換,再操做第二臺、第三臺...node

二、刪除一臺node節點linux

三、關閉升級機器負載勻衡nginx

四、刪除老版本軟連接,新版本作軟連接docker

五、拷貝老版本重啓腳本證書到新軟版本軟件目錄shell

六、重啓kubelet、kube-scheduler、kube-apiserver、kube-proxy、kube-controller-managerapi

1.2 刪除Node節點

hdss7-21執行服務器

[root@hdss7-21 opt]# kubectl get nodes -o wide
NAME                STATUS   ROLES    AGE    VERSION   INTERNAL-IP   EXTERNAL-IP   OS-IMAGE                KERNEL-VERSION           CONTAINER-RUNTIME
hdss7-21.host.com   Ready    <none>   3d7h   v1.19.2   10.4.7.21     <none>        CentOS Linux 7 (Core)   3.10.0-1127.el7.x86_64   docker://19.3.13
hdss7-22.host.com   Ready    master   3d7h   v1.19.2   10.4.7.22     <none>        CentOS Linux 7 (Core)   3.10.0-1127.el7.x86_64  
[root@hdss7-21 opt]# kubectl delete nodes hdss7-21.host.com
node "hdss7-21.host.com" deleted
[root@hdss7-21 opt]# kubectl get nodes 
NAME                STATUS   ROLES    AGE    VERSION
hdss7-22.host.com   Ready    master   3d7h   v1.19.2

1.3 註釋反代

hdss7-11和hdss7-12執行ide

[root@hdss7-11 ~]# grep -w " server 10.4.7.21:6443"  /etc/nginx/nginx.conf
#        server 10.4.7.21:6443     max_fails=3 fail_timeout=30s;
nginx -s reload

1.4 切目錄重啓

hdss7-21執行ui

[root@hdss7-21 ~]# mkdir /opt/net_version;cd /opt/net_version;
[root@hdss7-21 new_version]# ll
總用量 434140
-rw-r--r-- 1 root root 444555407 10月  8 2020 kubernetes-server-linux-amd64.tar.gz
tar xf kubernetes-server-linux-amd64.tar.gz 
[root@hdss7-21 new_version]# ll
總用量 434140
drwxr-xr-x 4 root root        79 5月   6 13:55 kubernetes
-rw-r--r-- 1 root root 444555407 10月  8 2020 kubernetes-server-linux-amd64.tar.gz
[root@hdss7-21 new_version]# mv kubernetes /opt/kubernetes-v1.15.12
[root@hdss7-21 new_version]# cd /opt/kubernetes-v1.15.12/
[root@hdss7-21 kubernetes-v1.15.12]# rm -rf kubernetes-src.tar.gz
[root@hdss7-21 kubernetes-v1.15.12]# cd server/bin
[root@hdss7-21 bin]# rm -f *.tar *_tag
[root@hdss7-21 bin]# cp -rf /opt/kubernetes-v1.19.2/server/bin/conf .
[root@hdss7-21 bin]# cp -rf /opt/kubernetes-v1.19.2/server/bin/certs .
[root@hdss7-21 bin]# cp /opt/kubernetes-v1.19.2/server/bin/kubelet.sh .
[root@hdss7-21 opt]# ln -sf /opt/kubernetes-v1.15.12 /opt/kubernetes
[root@hdss7-21 opt]# supervisorctl status kube-apiserver-7-21  kube-controller-manager-7-21 kube-proxy-7-21  kube-scheduler-7-21  
kube-apiserver-7-21              STOPPED   Oct 06 08:01 AM
kube-controller-manager-7-21     STOPPED   Oct 06 08:02 AM
kube-proxy-7-21                  STOPPED   Oct 06 08:02 AM
kube-scheduler-7-21              STOPPED   Oct 06 08:02 AM
[root@hdss7-21 opt]# supervisorctl start kube-apiserver-7-21  kube-controller-manager-7-21 kube-proxy-7-21  kube-scheduler-7-21 kube-kubelet-7-21
[root@hdss7-21 bin]# supervisorctl status                 
etcd-server-7-21                 RUNNING   pid 36332, uptime 2 days, 17:43:39
flanneld-7-21                    RUNNING   pid 130301, uptime 2 days, 12:33:31
kube-apiserver-7-21              RUNNING   pid 63354, uptime 0:09:44
kube-controller-manager-7-21     RUNNING   pid 63378, uptime 0:09:13
kube-kubelet-7-21                FATAL     Exited too quickly (process log may have details)
kube-proxy-7-21                  RUNNING   pid 63398, uptime 0:08:43
kube-scheduler-7-21              RUNNING   pid 63522, uptime 0:08:12

1.5 開啓Kubelet報錯

估計是關閉kubelet沒關好this

看啓動報錯日誌提示刪除文件再重啓
Please drain this node and delete the CPU manager checkpoint file "/data/kubelet/cpu_manager_state" before restarting Kubelet.
F1006 08:07:22.483670   62266 server.go:273] failed to run Kubelet: could not initialize checkpoint manager: could not restore state from checkpoint: checkpoint is corrupted
Please drain this node and delete the CPU manager checkpoint file "/data/kubelet/cpu_manager_state" before restarting K
[root@hdss7-21 bin]# rm -rf /data/kubelet/cpu_manager_state
[root@hdss7-21 bin]# supervisorctl start kube-kubelet-7-21 
[root@hdss7-21 bin]# supervisorctl status
etcd-server-7-21                 RUNNING   pid 36332, uptime 2 days, 17:44:39
flanneld-7-21                    RUNNING   pid 130301, uptime 2 days, 12:34:31
kube-apiserver-7-21              RUNNING   pid 63354, uptime 0:10:44
kube-controller-manager-7-21     RUNNING   pid 63378, uptime 0:10:13
kube-kubelet-7-21                RUNNING   pid 65092, uptime 0:00:37
kube-proxy-7-21                  RUNNING   pid 63398, uptime 0:09:43
kube-scheduler-7-21              RUNNING   pid 63522, uptime 0:09:12
[root@hdss7-21 bin]# kubectl get nodes
NAME                STATUS   ROLES    AGE         VERSION
hdss7-21.host.com   Ready    <none>   <invalid>   v1.15.12   # 已切換版本
hdss7-22.host.com   Ready    master   3d8h        v1.19.2

1.6 開啓反代

hdss7-11和hdss7-12執行

[root@hdss7-11 ~]# grep -w " server 10.4.7.21:6443"  /etc/nginx/nginx.conf
        server 10.4.7.21:6443     max_fails=3 fail_timeout=30s;
nginx -s reload
相關文章
相關標籤/搜索