在Kubernetes集群中,组件版本升级非常快,可能需要不停的进行升级。升级master和node的Docker和Containerd,逐台升级,确保升级节点被驱逐时集群内有足够的资源承载负载,对于生产环境在升级前做好充足验证,避免版本变化而导致的异常产生。本次升级是在测试环境kubernetes集群版本是 v1.17.11,docker版本是18.09.9,本次只升级docker以及对应的Containerd。
一.环境查看
1.查看集群版本
root@master01 ~]# kubectl get node -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
master01 Ready master 242d v1.17.11 10.10.20.3 <none> CentOS Linux 7 (Core) 3.10.0-1127.18.2.el7.x86_64 docker://18.9.9
master02 Ready master 2y136d v1.17.11 10.10.20.4 <none> CentOS Linux 7 (Core) 3.10.0-1062.el7.x86_64 docker://18.9.9
master03 Ready master 2y136d v1.17.11 10.10.20.5 <none> CentOS Linux 7 (Core) 3.10.0-1062.el7.x86_64 docker://18.9.9
work01 Ready <none> 2y134d v1.17.11 10.10.20.6 <none> CentOS Linux 7 (Core) 3.10.0-1062.el7.x86_64 docker://18.9.9
work02 Ready <none> 2y82d v1.17.11 10.10.20.7 <none> CentOS Linux 7 (Core) 3.10.0-1062.el7.x86_64 docker://18.9.9
2.查看docker以及Containerd
[root@master01 ~]# containerd -v && docker -v
containerd containerd.io 1.2.13 7ad184331fa3e55e52b890ea95e65ba581ae3429
Docker version 18.09.9, build 039a7df9ba
3.查看安装的docker相关的软件包
[root@master01 ~]# rpm -qa | grep docker
docker-ce-cli-18.09.9-3.el7.x86_64
docker-ce-18.09.9-3.el7.x86_64
4.查看containered对应的软件包
[root@master01 ~]# rpm -qa | grep container
containerd.io-1.2.13-3.1.el7.x86_64
container-selinux-2.107-3.el7.noarch
二.升级过程
先升级node节点,再升级master,采用逐台升级,本次升级的docker版本从ocker-ce-18.09.9-3.el7.x86_64升级到docker-ce-20.10.12-3.el7.x86_64.
1.配置docker的yum源
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
2.腾空节点(首先在node节点执行,之后再在master节点执行),本次以worker02为例。
kubectl drain work02 --ignore-daemonsets --delete-local-data --force
输出:
node/work02 cordoned
WARNING: deleting Pods not managed by ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet: default/init-demo, default/kucc4
evicting pod "init-demo"
evicting pod "kucc4"
evicting pod "ds.kusc00201-7c7bdb685c-l7xkk"
evicting pod "mysql-doraemon-74874995b4-vnpgp"
evicting pod "nginx-5d78bdd449-9t2zx"
pod/ds.kusc00201-7c7bdb685c-l7xkk evicted
pod/nginx-5d78bdd449-9t2zx evicted
pod/mysql-doraemon-74874995b4-vnpgp evicted
pod/init-demo evicted
pod/kucc4 evicted
node/work02 evicted
2.停掉拟升级节点的kubelet和docker服务
systemctl stop kubelet
systemctl stop docker
3.查看docket有哪些版本
[root@master01 ~]# yum list docker-ce --showduplicates | sort -r
输出:
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
* updates: mirrors.huaweicloud.com
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
Installed Packages
* extras: mirrors.tuna.tsinghua.edu.cn
docker-ce.x86_64 3:20.10.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.17-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.16-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.15-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.14-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.13-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.12-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.11-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.10-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.0-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.15-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.14-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.13-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.12-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.11-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.10-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.0-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.9-3.el7 @docker-ce-stable
docker-ce.x86_64 3:18.09.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.3.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.2.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable
docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
* base: mirrors.huaweicloud.com
Available Packages
4.卸载旧版本docker
-bash-4.2# yum remove docker docker-ce-cli
输出:
Loaded plugins: fastestmirror
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
No Match for argument: docker
Resolving Dependencies
--> Running transaction check
---> Package docker-ce-cli.x86_64 1:18.09.9-3.el7 will be erased
--> Processing Dependency: docker-ce-cli for package: 3:docker-ce-18.09.9-3.el7.x86_64
--> Running transaction check
---> Package docker-ce.x86_64 3:18.09.9-3.el7 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================================================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================================================================================================================================
Removing:
docker-ce-cli x86_64 1:18.09.9-3.el7 @docker-ce-stable 72 M
Removing for dependencies:
docker-ce x86_64 3:18.09.9-3.el7 @docker-ce-stable 90 M
Transaction Summary
==============================================================================================================================================================================================================================================================================
Remove 1 Package (+1 Dependent package)
Installed size: 163 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
/usr/bin/dockerd has not been configured as an alternative for dockerd
Erasing : 3:docker-ce-18.09.9-3.el7.x86_64 1/2
Erasing : 1:docker-ce-cli-18.09.9-3.el7.x86_64 2/2
Verifying : 1:docker-ce-cli-18.09.9-3.el7.x86_64 1/2
Verifying : 3:docker-ce-18.09.9-3.el7.x86_64 2/2
Removed:
docker-ce-cli.x86_64 1:18.09.9-3.el7
Dependency Removed:
docker-ce.x86_64 3:18.09.9-3.el7
Complete!
5. 升级docker和containerd为最新版本
-bash-4.2# yum install docker-ce-20.10.12-3.el7
输出:
Loaded plugins: fastestmirror
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.huaweicloud.com
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 3:20.10.12-3.el7 will be installed
--> Processing Dependency: containerd.io >= 1.4.1 for package: 3:docker-ce-20.10.12-3.el7.x86_64
--> Processing Dependency: docker-ce-cli for package: 3:docker-ce-20.10.12-3.el7.x86_64
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-20.10.12-3.el7.x86_64
--> Running transaction check
---> Package containerd.io.x86_64 0:1.2.13-3.2.el7 will be updated
---> Package containerd.io.x86_64 0:1.6.8-3.1.el7 will be an update
---> Package docker-ce-cli.x86_64 1:20.10.17-3.el7 will be installed
--> Processing Dependency: docker-scan-plugin(x86-64) for package: 1:docker-ce-cli-20.10.17-3.el7.x86_64
---> Package docker-ce-rootless-extras.x86_64 0:20.10.17-3.el7 will be installed
--> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-20.10.17-3.el7.x86_64
--> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-20.10.17-3.el7.x86_64
--> Running transaction check
---> Package docker-scan-plugin.x86_64 0:0.17.0-3.el7 will be installed
---> Package fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 will be installed
--> Processing Dependency: libfuse3.so.3(FUSE_3.2)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3(FUSE_3.0)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3()(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
---> Package slirp4netns.x86_64 0:0.4.3-4.el7_8 will be installed
--> Running transaction check
---> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================================================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================================================================================================================================
Installing:
docker-ce x86_64 3:20.10.12-3.el7 docker-ce-stable 23 M
Installing for dependencies:
docker-ce-cli x86_64 1:20.10.17-3.el7 docker-ce-stable 29 M
docker-ce-rootless-extras x86_64 20.10.17-3.el7 docker-ce-stable 8.2 M
docker-scan-plugin x86_64 0.17.0-3.el7 docker-ce-stable 3.7 M
fuse-overlayfs x86_64 0.7.2-6.el7_8 extras 54 k
fuse3-libs x86_64 3.6.1-4.el7 extras 82 k
slirp4netns x86_64 0.4.3-4.el7_8 extras 81 k
Updating for dependencies:
containerd.io x86_64 1.6.8-3.1.el7 docker-ce-stable 33 M
Transaction Summary
==============================================================================================================================================================================================================================================================================
Install 1 Package (+6 Dependent packages)
Upgrade ( 1 Dependent package)
Total download size: 97 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/8): containerd.io-1.6.8-3.1.el7.x86_64.rpm | 33 MB 00:00:11
(2/8): docker-ce-20.10.12-3.el7.x86_64.rpm | 23 MB 00:00:11
(3/8): docker-ce-rootless-extras-20.10.17-3.el7.x86_64.rpm | 8.2 MB 00:00:02
(4/8): fuse3-libs-3.6.1-4.el7.x86_64.rpm | 82 kB 00:00:00
(5/8): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm | 54 kB 00:00:00
(6/8): slirp4netns-0.4.3-4.el7_8.x86_64.rpm | 81 kB 00:00:00
(7/8): docker-scan-plugin-0.17.0-3.el7.x86_64.rpm | 3.7 MB 00:00:00
(8/8): docker-ce-cli-20.10.17-3.el7.x86_64.rpm | 29 MB 00:00:04
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 6.0 MB/s | 97 MB 00:00:16
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : docker-scan-plugin-0.17.0-3.el7.x86_64 1/9
Installing : 1:docker-ce-cli-20.10.17-3.el7.x86_64 2/9
Installing : slirp4netns-0.4.3-4.el7_8.x86_64 3/9
Updating : containerd.io-1.6.8-3.1.el7.x86_64 4/9
Installing : fuse3-libs-3.6.1-4.el7.x86_64 5/9
Installing : fuse-overlayfs-0.7.2-6.el7_8.x86_64 6/9
Installing : 3:docker-ce-20.10.12-3.el7.x86_64 7/9
Installing : docker-ce-rootless-extras-20.10.17-3.el7.x86_64 8/9
Cleanup : containerd.io-1.2.13-3.2.el7.x86_64 9/9
Verifying : fuse3-libs-3.6.1-4.el7.x86_64 1/9
Verifying : containerd.io-1.6.8-3.1.el7.x86_64 2/9
Verifying : docker-ce-rootless-extras-20.10.17-3.el7.x86_64 3/9
Verifying : 1:docker-ce-cli-20.10.17-3.el7.x86_64 4/9
Verifying : slirp4netns-0.4.3-4.el7_8.x86_64 5/9
Verifying : docker-scan-plugin-0.17.0-3.el7.x86_64 6/9
Verifying : fuse-overlayfs-0.7.2-6.el7_8.x86_64 7/9
Verifying : 3:docker-ce-20.10.12-3.el7.x86_64 8/9
Verifying : containerd.io-1.2.13-3.2.el7.x86_64 9/9
Installed:
docker-ce.x86_64 3:20.10.12-3.el7
Dependency Installed:
docker-ce-cli.x86_64 1:20.10.17-3.el7 docker-ce-rootless-extras.x86_64 0:20.10.17-3.el7 docker-scan-plugin.x86_64 0:0.17.0-3.el7 fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 fuse3-libs.x86_64 0:3.6.1-4.el7 slirp4netns.x86_64 0:0.4.3-4.el7_8
Dependency Updated:
containerd.io.x86_64 0:1.6.8-3.1.el7
Complete!
6.启动docker服务
-bash-4.2# systemctl restart docker
查看状态
-bash-4.2# systemctl status docker
输出:
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2022-08-31 10:59:48 CST; 1s ago
Docs: https://docs.docker.com
Main PID: 3685 (dockerd)
Tasks: 20
Memory: 42.7M
CGroup: /system.slice/docker.service
└─3685 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Aug 31 10:59:47 work02 dockerd[3685]: time="2022-08-31T10:59:47.056821559+08:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
Aug 31 10:59:47 work02 dockerd[3685]: time="2022-08-31T10:59:47.211745089+08:00" level=info msg="Loading containers: start."
Aug 31 10:59:48 work02 dockerd[3685]: time="2022-08-31T10:59:48.126311336+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address"
Aug 31 10:59:48 work02 dockerd[3685]: time="2022-08-31T10:59:48.445690355+08:00" level=info msg="Loading containers: done."
Aug 31 10:59:48 work02 dockerd[3685]: time="2022-08-31T10:59:48.534402456+08:00" level=info msg="Docker daemon" commit=459d0df graphdriver(s)=overlay2 version=20.10.12
Aug 31 10:59:48 work02 dockerd[3685]: time="2022-08-31T10:59:48.534728281+08:00" level=info msg="Daemon has completed initialization"
Aug 31 10:59:48 work02 systemd[1]: Started Docker Application Container Engine.
Aug 31 10:59:48 work02 dockerd[3685]: time="2022-08-31T10:59:48.627941713+08:00" level=info msg="API listen on /var/run/docker.sock"
Aug 31 10:59:48 work02 dockerd[3685]: time="2022-08-31T10:59:48.712673010+08:00" level=warning msg="Published ports are discarded when using host network mode"
Aug 31 10:59:48 work02 dockerd[3685]: time="2022-08-31T10:59:48.985802600+08:00" level=warning msg="Published ports are discarded when using host network mode"
7.检查版本
-bash-4.2# containerd -v && docker -v
containerd containerd.io 1.6.8 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
Docker version 20.10.17, build 100c701
8.查看软件docker安装包
-bash-4.2# rpm -qa | grep docker
输出:
docker-ce-cli-20.10.17-3.el7.x86_64
docker-scan-plugin-0.17.0-3.el7.x86_64
docker-ce-20.10.12-3.el7.x86_64
docker-ce-rootless-extras-20.10.17-3.el7.x86_64
9.查看containerd安装包
-bash-4.2# rpm -qa | grep containerd
containerd.io-1.6.8-3.1.el7.x86_64
10.查看docker镜像
-bash-4.2# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox latest beae173ccac6 8 months ago 1.24MB
nginx latest 605c77e624dd 8 months ago 141MB
memcached latest 752e592c22f1 8 months ago 89.1MB
redis latest 7614ae9453d1 8 months ago 113MB
consul latest 76802375bc5c 8 months ago 118MB
nginx <none> 7e4d58f0e5f3 23 months ago 133MB
redis <none> 41de2cc0b30e 24 months ago 104MB
busybox <none> edabd795951a 24 months ago 1.22MB
nginx <none> 4bb46517cac3 2 years ago 133MB
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy v1.17.11 597c722f6011 2 years ago 117MB
consul <none> 6adcb25542ed 2 years ago 122MB
memcached <none> 9541a03b5007 2 years ago 82.3MB
jenkins/jenkins lts 5d1103b93f92 2 years ago 656MB
nginx 1.16 dfcfd8e9a5d3 2 years ago 127MB
quay.io/coreos/flannel v0.12.0-amd64 4e9f801d2217 2 years ago 52.8MB
polinux/stress latest df58d15b053d 2 years ago 9.74MB
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy v1.16.4 091df896d78f 2 years ago 86.1MB
registry.cn-hangzhou.aliyuncs.com/google_containers/coredns 1.6.5 70f311871ae1 2 years ago 41.6MB
registry.cn-beijing.aliyuncs.com/abcdocker/jenkins v1.2 1040138b5448 3 years ago 1.01GB
rancher/rancher-agent v2.2.4 7b50ddb5354c 3 years ago 290MB
quay.io/prometheus/node-exporter v0.18.1 e5a616e4b9cf 3 years ago 22.9MB
quay.io/coreos/kube-rbac-proxy v0.4.1 70eeaa7791f2 3 years ago 41.3MB
mysql 5.6.41 085b9b6ec8a9 3 years ago 256MB
quay.io/external_storage/nfs-client-provisioner latest 16d2f904b0d8 4 years ago 45.5MB
cnych/jenkins jnlp d68e6cfb2be2 4 years ago 1.29GB
registry.cn-hangzhou.aliyuncs.com/google_containers/pause 3.1 da86e6ba6ca1 4 years ago 742kB
nginx 1.12.0 313ec0a602bc 5 years ago 107MB
nginx 1.11.9 cc1b61406712 5 years ago 182MB
nginx 1.9.1 94ec7e53edfc 7 years ago 133MB
原来升级前的数据没有丢失
11.启用kubelet
-bash-4.2# systemctl restart kubelet
-bash-4.2# systemctl status kubelet
● kubelet.service - kubelet: The Kubernetes Node Agent
Loaded: loaded (/usr/lib/systemd/system/kubelet.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/kubelet.service.d
└─10-kubeadm.conf
Active: active (running) since Wed 2022-08-31 11:04:37 CST; 6s ago
Docs: https://kubernetes.io/docs/
Main PID: 6525 (kubelet)
Tasks: 15
Memory: 21.5M
CGroup: /system.slice/kubelet.service
└─6525 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --cgroup-driver=systemd --network-plugin=cni --pod-infra-container-image=registry.cn-hangz...
Aug 31 11:04:38 work02 kubelet[6525]: I0831 11:04:38.580320 6525 docker_service.go:260] Docker Info: &{ID:ENBK:MTLY:ZF26:J5GJ:4GGV:E2Q3:JZQR:U7FI:ODLB:AJTF:KQWL:IJWL Containers:14 ContainersRunning:7 ContainersPaused:0 ContainersStopped:7 Imag...pports d_type true] [
Aug 31 11:04:38 work02 kubelet[6525]: I0831 11:04:38.580770 6525 docker_service.go:273] Setting cgroupDriver to systemd
Aug 31 11:04:38 work02 kubelet[6525]: I0831 11:04:38.631428 6525 remote_runtime.go:59] parsed scheme: ""
Aug 31 11:04:38 work02 kubelet[6525]: I0831 11:04:38.631547 6525 remote_runtime.go:59] scheme "" not registered, fallback to default scheme
Aug 31 11:04:38 work02 kubelet[6525]: I0831 11:04:38.631771 6525 passthrough.go:48] ccResolverWrapper: sending update to cc: {[{/var/run/dockershim.sock 0 <nil>}] <nil>}
Aug 31 11:04:38 work02 kubelet[6525]: I0831 11:04:38.631855 6525 clientconn.go:577] ClientConn switching balancer to "pick_first"
Aug 31 11:04:38 work02 kubelet[6525]: I0831 11:04:38.632031 6525 remote_image.go:50] parsed scheme: ""
Aug 31 11:04:38 work02 kubelet[6525]: I0831 11:04:38.632053 6525 remote_image.go:50] scheme "" not registered, fallback to default scheme
Aug 31 11:04:38 work02 kubelet[6525]: I0831 11:04:38.632079 6525 passthrough.go:48] ccResolverWrapper: sending update to cc: {[{/var/run/dockershim.sock 0 <nil>}] <nil>}
Aug 31 11:04:38 work02 kubelet[6525]: I0831 11:04:38.632097 6525 clientconn.go:577] ClientConn switching balancer to "pick_first"
Hint: Some lines were ellipsized, use -l to show in full.
12.master节点查看升级后的集群状态
[root@master01 ~]# kubectl get node -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
master01 Ready master 242d v1.17.11 10.10.20.3 <none> CentOS Linux 7 (Core) 3.10.0-1127.18.2.el7.x86_64 docker://18.9.9
master02 Ready master 2y137d v1.17.11 10.10.20.4 <none> CentOS Linux 7 (Core) 3.10.0-1062.el7.x86_64 docker://18.9.9
master03 Ready master 2y137d v1.17.11 10.10.20.5 <none> CentOS Linux 7 (Core) 3.10.0-1062.el7.x86_64 docker://18.9.9
work01 Ready <none> 2y135d v1.17.11 10.10.20.6 <none> CentOS Linux 7 (Core) 3.10.0-1062.el7.x86_64 docker://18.9.9
work02 Ready,SchedulingDisabled <none> 2y82d v1.17.11 10.10.20.7 <none> CentOS Linux 7 (Core) 3.10.0-1062.el7.x86_64 docker://20.10.12
最后一行线上docker版本已经升级
13.解除节点的禁止调度(master节点操作)
[root@master01 ~]# kubectl uncordon work02
输出:
node/work02 uncordoned
以上即完成node节点的升级
二.其他worker节点的升级
采用逐台升级,当一台升级完成后,采用以上步骤,再升级其它节点。
三.master节点升级
如果是单主单从,node升级会有风险,可能导致业务异常;
如果是单台master,且master没有参与集群负载,此时master上的pod为静态pod,此时不需要执行驱逐节点操作,停止docker和kubelet,升级docker即可;
如果是单台master,master参与集群负载,此时驱逐后进行升级。master执行驱逐操作后,工作负载pod会迁移至其它节点,系统pod作为静态pod还会保留,停止docker和kubelet,升级docker即可;
如果是多master,多node,且master没有参与集群负载,此时master上的pod为静态pod,此时不需要执行驱逐节点操作,停止docker和kubelet,升级docker即可;
如果是多master,多node,master参与集群负载,此时驱逐后进行升级,按步骤2顺序进行升级。master执行驱逐操作后,工作负载pod会迁移至其它节点,系统pod作为静态pod还会保留,停止docker和kubelet,升级docker即可。
如下命令可以完成节点docker升级
kubectl drain node_name --ignore-daemonsets --delete-local-data --force
systemctl stop kubelet && systemctl stop docker
yum makecache
yum install docker-ce-20.10.12-3.el7 -y
systemctl restart docker && systemctl restart kubelet