可以看到我们的版本可以升级到v1.24.4
### 显示版本差异
[upgrade/diff] Reading configuration from the cluster…
[upgrade/diff] FYI: You can look at this config file with ‘kubectl -n kube-system get cm kubeadm-config -o yaml’
— /etc/kubernetes/manifests/kube-apiserver.yaml
+++ new manifest
@@ -40,7 +40,7 @@
- --service-cluster-ip-range=10.96.0.0/12
- --tls-cert-file=/etc/kubernetes/pki/apiserver.crt
- --tls-private-key-file=/etc/kubernetes/pki/apiserver.key
### 查看kubeadm版本
kubeadm | 1.25.0-00 | https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial/main amd64 Packages
kubeadm | 1.24.4-00 | https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial/main amd64 Packages
可以看到我们最新的版本时1.25.0以及1.24.4
### 升级
升级kubeadm
sudo apt-get install kubeadm=1.24.4-00
将 Kubernetes 集群升级到指定版本
sudo kubeadm upgrade apply 1.24.4
### 升级master节点
开启调度保护
node/master1 cordoned
NAME STATUS ROLES AGE VERSION
master1 Ready,SchedulingDisabled control-plane 145m v1.24.1
node1 Ready 121m v1.24.1
node2 Ready 108m v1.24.1
node/master1 already cordoned
WARNING: ignoring DaemonSet-managed Pods: kube-flannel/kube-flannel-ds-8lfc4, kube-system/kube-proxy-km8gx
evicting pod kube-system/coredns-74586cf9b6-fq7gg
evicting pod kube-system/coredns-74586cf9b6-2pk2p
pod/coredns-74586cf9b6-fq7gg evicted
pod/coredns-74586cf9b6-2pk2p evicted
node/master1 drained
更新节点配置
sudo kubeadm upgrade node
升级kublet组件
sudo apt-get install -y kubelet=1.24.4-00 kubectl=1.24.4-00
取消调度保护
kubectl uncordon master1
NAME STATUS ROLES AGE VERSION
master1 Ready control-plane 149m v1.24.4
node1 Ready 125m v1.24.1
node2 Ready 113m v1.24.1
### 升级node节点
开启调度保护(master节点执行)
node/node1 cordoned
NAME STATUS ROLES AGE VERSION
master1 Ready control-plane 151m v1.24.4
node1 Ready,SchedulingDisabled 127m v1.24.1
node2 Ready 115m v1.24.1
node/node1 already cordoned
WARNING: ignoring DaemonSet-managed Pods: kube-flannel/kube-flannel-ds-q8dpb, kube-system/kube-proxy-g7mbw
evicting pod kube-system/coredns-74586cf9b6-782sb
evicting pod default/myhello-rc-bxlbg
evicting pod default/myhello-rc-792dl
evicting pod default/myhello-rc-vxz47
pod/myhello-rc-vxz47 evicted
pod/myhello-rc-792dl evicted
pod/myhello-rc-bxlbg evicted
pod/coredns-74586cf9b6-782sb evicted
node/node1 drained
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
myhello-rc-2bmwh 1/1 Running 0 22s 10.244.4.7 node2
myhello-rc-bmln7 1/1 Running 0 22s 10.244.4.9 node2
myhello-rc-kjftb 1/1 Running 0 70m 10.244.4.3 node2
myhello-rc-pk6vc 1/1 Running 0 22s 10.244.4.8 node2
myhello-rc-wdvt6 1/1 Running 0 70m 10.244.4.2 node2
升级kublet组件(node节点执行)
sudo apt-get install -y kubelet=1.24.4-00 kubectl=1.24.4-00
更新节点配置(node节点执行)
sudo kubeadm upgrade node
取消调度保护(master节点执行)
kubectl uncordon node1
NAME STATUS ROLES AGE VERSION
master1 Ready control-plane 149m v1.24.4
node1 Ready 125m v1.24.1
node2 Ready 113m v1.24.1
### 升级完成