Bootstrap

二进制平滑升级Kubernets集群

升级说明

Kubernetes 集群小版本升级基本上是只需要 要更新二进制文件即可。如果大版本升级需要注意kubelet参数的变化,以及其他组件升级之后的变化。 由于Kubernete版本更新过快许多依赖并没有解决完善,并不建议生产环境使用较新版本。

生产环境升级建议再测试环境反复测试验证

https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.21.md#downloads-for-v1217

组件 升级前 升级后
Etcd 3.4.13 无需升级
kube-apiserver 1.20.13 1.21.7
kube-scheduler 1.20.13 1.21.7
kube-controller-manager 1.20.13 1.21.7
kubectl 1.20.13 1.21.7
kube-proxy 1.20.13 1.21.7
kubelet 1.20.13 1.21.7
calico 3.15.3 3.21.1
coredns 1.7.0 1.8.6

升级Master

Master01

# 备份
[root@k8s-master01 ~]# cd /usr/local/bin/
[root@k8s-master01 bin]# cp kube-apiserver kube-controller-manager kube-scheduler kubectl /tmp

# 下载安装包
[root@k8s-master01 ~]# wget https://storage.googleapis.com/kubernetes-release/release/v1.21.7/kubernetes-server-linux-amd64.tar.gz
[root@k8s-master01 ~]# tar zxf kubernetes-server-linux-amd64.tar.gz

# 停止服务
[root@k8s-master01 ~]# systemctl stop kube-apiserver
[root@k8s-master01 ~]# systemctl stop kube-controller-manager
[root@k8s-master01 ~]# systemctl stop kube-scheduler
# 更新包
[root@k8s-master01 bin]# cd /root/kubernetes/server/bin/
[root@k8s-master01 bin]# ll
total 1075472
-rwxr-xr-x 1 root root  50810880 Nov 17 22:52 apiextensions-apiserver
-rwxr-xr-x 1 root root  44867584 Nov 17 22:52 kubeadm
-rwxr-xr-x 1 root root  48586752 Nov 17 22:52 kube-aggregator
-rwxr-xr-x 1 root root 122204160 Nov 17 22:52 kube-apiserver
-rw-r--r-- 1 root root         8 Nov 17 22:50 kube-apiserver.docker_tag
-rw------- 1 root root 126985216 Nov 17 22:50 kube-apiserver.tar
-rwxr-xr-x 1 root root 116404224 Nov 17 22:52 kube-controller-manager
-rw-r--r-- 1 root root         8 Nov 17 22:50 kube-controller-manager.docker_tag
-rw------- 1 root root 121185280 Nov 17 22:50 kube-controller-manager.tar
-rwxr-xr-x 1 root root  46669824 Nov 17 22:52 kubectl
-rwxr-xr-x 1 root root  55317704 Nov 17 22:52 kubectl-convert
-rwxr-xr-x 1 root root 118390192 Nov 17 22:52 kubelet
-rwxr-xr-x 1 root root  43376640 Nov 17 22:52 kube-proxy
-rw-r--r-- 1 root root         8 Nov 17 22:50 kube-proxy.docker_tag
-rw------- 1 root root 105378304 Nov 17 22:50 kube-proxy.tar
-rwxr-xr-x 1 root root  47349760 Nov 17 22:52 kube-scheduler
-rw-r--r-- 1 root root         8 Nov 17 22:50 kube-scheduler.docker_tag
-rw------- 1 root root  52130816 Nov 17 22:50 kube-scheduler.tar
-rwxr-xr-x 1 root root   1593344 Nov 17 22:52 mounter
[root@k8s-master01 bin]# cp kube-api
;