具体步骤可以参考kubernetes官网:https://kubernetes.io/zh-cn/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade/
确定升级到哪个版本
示例是从同版本1.28.2 升级到1.28.7
所以使用操作系统的包管理器找到最新可按照的版本中,是否有需要的补丁版本
sudo yum list --showduplicates kubeadm --disableexcludes=kubernetes
点击查看返回的版本信息
[root@whdcinthe004 ~]# yum list --showduplicates kubeadm --disableexcludes=kubernetes
Last metadata expiration check: 1:30:29 ago on Wed 13 Mar 2024 08:22:56 AM CST.
Installed Packages
kubeadm.x86_64 1.28.2-0 @kubernetes
Available Packages
kubeadm.aarch64 1.28.0-150500.1.1 kubernetes
kubeadm.ppc64le 1.28.0-150500.1.1 kubernetes
kubeadm.s390x 1.28.0-150500.1.1 kubernetes
kubeadm.src 1.28.0-150500.1.1 kubernetes
kubeadm.x86_64 1.28.0-150500.1.1 kubernetes
kubeadm.aarch64 1.28.1-150500.1.1 kubernetes
kubeadm.ppc64le 1.28.1-150500.1.1 kubernetes
kubeadm.s390x 1.28.1-150500.1.1 kubernetes
kubeadm.src 1.28.1-150500.1.1 kubernetes
kubeadm.x86_64 1.28.1-150500.1.1 kubernetes
kubeadm.aarch64 1.28.2-150500.1.1 kubernetes
kubeadm.ppc64le 1.28.2-150500.1.1 kubernetes
kubeadm.s390x 1.28.2-150500.1.1 kubernetes
kubeadm.src 1.28.2-150500.1.1 kubernetes
kubeadm.x86_64 1.28.2-150500.1.1 kubernetes
kubeadm.aarch64 1.28.3-150500.1.1 kubernetes
kubeadm.ppc64le 1.28.3-150500.1.1 kubernetes
kubeadm.s390x 1.28.3-150500.1.1 kubernetes
kubeadm.src 1.28.3-150500.1.1 kubernetes
kubeadm.x86_64 1.28.3-150500.1.1 kubernetes
kubeadm.aarch64 1.28.4-150500.1.1 kubernetes
kubeadm.ppc64le 1.28.4-150500.1.1 kubernetes
kubeadm.s390x 1.28.4-150500.1.1 kubernetes
kubeadm.src 1.28.4-150500.1.1 kubernetes
kubeadm.x86_64 1.28.4-150500.1.1 kubernetes
kubeadm.aarch64 1.28.5-150500.1.1 kubernetes
kubeadm.ppc64le 1.28.5-150500.1.1 kubernetes
kubeadm.s390x 1.28.5-150500.1.1 kubernetes
kubeadm.src 1.28.5-150500.1.1 kubernetes
kubeadm.x86_64 1.28.5-150500.1.1 kubernetes
kubeadm.aarch64 1.28.6-150500.1.1 kubernetes
kubeadm.ppc64le 1.28.6-150500.1.1 kubernetes
kubeadm.s390x 1.28.6-150500.1.1 kubernetes
kubeadm.src 1.28.6-150500.1.1 kubernetes
kubeadm.x86_64 1.28.6-150500.1.1 kubernetes
kubeadm.aarch64 1.28.7-150500.1.1 kubernetes
kubeadm.ppc64le 1.28.7-150500.1.1 kubernetes
kubeadm.s390x 1.28.7-150500.1.1 kubernetes
kubeadm.src 1.28.7-150500.1.1 kubernetes
kubeadm.x86_64 1.28.7-150500.1.1
升级控制平面节点kubeadm
控制面节点上的升级过程应该每次处理一个节点。 首先选择一个要先行升级的控制面节点。该节点上必须拥有 /etc/kubernetes/admin.conf
文件。
1. 升级kubeadm:
# 按照所需要版本 1.28.7-* 中的 x
sudo yum install -y kubeadm-'1.28.7-*' --disableexcludes=kubernetes
2. 验证下载操作正常,并且 kubeadm 版本正确:
[root@whdcinthe004 ~]# kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"28", GitVersion:"v1.28.7", GitCommit:"c8dcb00be9961ec36d141d2e4103f85f92bcf291", GitTreeState:"clean", BuildDate:"2024-02-14T10:39:01Z", GoVersion:"go1.21.7", Compiler:"gc", Platform:"linux/amd64"}
3.验证升级计划
sudo kubeadm upgrade plan
4.升级kubeadm
sudo kubeadm upgrade apply v1.28.7
#要注意,会提问你是否要保护,记得输入y
#[upgrade] Are you sure you want to proceed? [y/N]: y
结束后,你会看到:
[upgrade/successful] SUCCESS! Your cluster was upgraded to "v1.28.7". Enjoy!
[upgrade/kubelet] Now that your control plane is upgraded, please proceed with upgrading your kubelets if you haven't already done so.
保护节点
将节点标记为不可调度并驱逐所有负载,准备节点的维护:
kubectl drain <node-to-drain> --ignore-daemonsets
#node-to-drain指的节点名称,比如我这里,需要替换命令为 kubectl drain whdcinthe004.cn.infra --ignore-daemonsets
升级Kubelet kubectl
- 命令
yum install -y kubelet-'1.28.7-*' kubectl-'1.28.7-*' --disableexcludes=kubernetes
- 重启kubelet
sudo systemctl daemon-reload
sudo systemctl restart kubelet
解除节点保护
kubectl uncordon <node-to-uncordon>
# kubectl uncordon whdcinthe004.cn.infra
验证集群状态:
kubectl get nodes
标签:kubernetes,64,1.28,150500.1,master,kubeadm,节点
From: https://www.cnblogs.com/rinya09/p/18070250