kubenetes v1.25.0 升级 v 1.25.1

升级K8s 版本 v1.25.0 -> v1.25.1 :

# 升级之前 v1.25.0 :
[root@k8s-master-1 ~]# kubectl get node -o wide
NAME           STATUS   ROLES           AGE   VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE                KERNEL-VERSION           CONTAINER-RUNTIME
k8s-master-1   Ready    control-plane   39d   v1.25.0   192.168.3.101   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-1     Ready    <none>          39d   v1.25.0   192.168.3.104   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-2     Ready    <none>          39d   v1.25.0   192.168.3.105   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-3     Ready    <none>          39d   v1.25.0   192.168.3.106   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21

# 升级之后 v1.25.1 :
[root@k8s-master-1 ~]# kubectl get node -o wide
NAME           STATUS   ROLES           AGE   VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE                KERNEL-VERSION           CONTAINER-RUNTIME
k8s-master-1   Ready    control-plane   39d   v1.25.1   192.168.3.101   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-1     Ready    <none>          39d   v1.25.1   192.168.3.104   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-2     Ready    <none>          39d   v1.25.1   192.168.3.105   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-3     Ready    <none>          39d   v1.25.1   192.168.3.106   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21

升级管理节点(master) 9步 :

1  查找最新版本号:
yum list --showduplicates kubeadm

2  升级kubeadm
yum install -y kubeadm-1.25.1-0

3  驱逐Node上的pod,并设置为不可调度(有啥提示参数要加的都加上):
kubectl drain k8s-master-1 --ignore-daemonsets

4  检查集群是否可以升级,并获取可以升级的版本(直接升级1.25的最新版本 可以忽略版本号,如果是升级到次新版本 主要要加上版本号):
 kubeadm upgrade plan 1.25.1-0

5  根据提示进行下一步操作:
kubeadm upgrade apply v1.25.1 --etcd-upgrade=false      # --etcd-upgrade=false 默认为true即升级Etcd, 可以用此参数不升级Etcd.

6 升级kubectl 和 kubelet:
yum install kubectl-1.25.1 kubelet-1.25.1 -y

7 重启kubelet:
systemctl daemon-reload
systemctl restart kubelet

8  取消不可调度,重新上线:
kubectl uncordon k8s-master-1

9 查看升级后的master版本: 
kubectl get node -o wide

升级工作节点(node) 7步:

1 升级kubeadm:
yum  install -y kubeadm-1.25.1

2 驱逐Node节点上的pod,且不可调度(master 端操作):
kubectl drain k8s-node-3 --ignore-daemonsets

3 升级kubelet 配置:
kubeadm upgrade node

4 升级kubectl 和 kubelet:
yum install kubectl-1.25.1 kubelet-1.25.1 -y

5 重启kubelet:
systemctl daemon-reload
systemctl restart kubelet

6 取消不可调度,重新上线(master 端操作):
kubectl uncordon k8s-node-3

7 查看升级后的Node节点版本(master 端操作): 
kubectl get node -o wide

至此 Master + Node 升级完成,下面是详细信息,略过即可


升级主节点(k8s-master-1):

1  查找最新版本号:
yum list --showduplicates kubeadm

[root@k8s-master-1 ~]# yum list --showduplicates kubeadm | grep 1.25
kubeadm.x86_64                       1.25.0-0                        @kubernetes
kubeadm.x86_64                       1.25.0-0                        kubernetes 
kubeadm.x86_64                       1.25.1-0                        kubernetes 
kubeadm.x86_64                       1.25.2-0                        kubernetes 
kubeadm.x86_64                       1.25.3-0                        kubernetes 
kubeadm.x86_64                       1.25.4-0                        kubernetes 
kubeadm.x86_64                       1.25.5-0                        kubernetes 


2  升级kubeadm
yum install -y kubeadm-1.25.1-0

3  驱逐Node上的pod,并设置为不可调度(有啥提示参数要加的都加上):
kubectl drain k8s-master-1 --ignore-daemonsets

[root@k8s-master-1 ~]# kubectl get node -o wide
NAME           STATUS                     ROLES           AGE   VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE                KERNEL-VERSION           CONTAINER-RUNTIME
k8s-master-1   Ready,SchedulingDisabled   control-plane   39d   v1.25.0   192.168.3.101   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-1     Ready                      <none>          39d   v1.25.0   192.168.3.104   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-2     Ready                      <none>          39d   v1.25.0   192.168.3.105   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-3     Ready                      <none>          39d   v1.25.0   192.168.3.106   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21


4  检查集群是否可以升级,并获取可以升级的版本(直接升级1.25的最新版本 可以忽略版本号,如果是升级到次新版本 主要要加上版本号):
 kubeadm upgrade plan 1.25.1-0

[root@k8s-master-1 ~]# [root@k8s-master-1 ~]# kubeadm upgrade plan 1.25.1-0
[upgrade/config] Making sure the configuration is correct:
[upgrade/config] Reading configuration from the cluster...
[upgrade/config] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
[preflight] Running pre-flight checks.
[upgrade] Running cluster health checks
[upgrade] Fetching available versions to upgrade to
[upgrade/versions] Cluster version: v1.25.0
[upgrade/versions] kubeadm version: v1.25.1
[upgrade/versions] Target version: 1.25.1-0
[upgrade/versions] Latest version in the v1.25 series: 1.25.1-0

Components that must be upgraded manually after you have upgraded the control plane with 'kubeadm upgrade apply':
COMPONENT   CURRENT       TARGET
kubelet     4 x v1.25.0   1.25.1-0                         #  这里很重要

Upgrade to the latest version in the v1.25 series:

COMPONENT                 CURRENT   TARGET
kube-apiserver            v1.25.0   1.25.1-0
kube-controller-manager   v1.25.0   1.25.1-0
kube-scheduler            v1.25.0   1.25.1-0
kube-proxy                v1.25.0   1.25.1-0
CoreDNS                   v1.9.3    v1.9.3
etcd                      3.5.4-0   3.5.4-0

You can now apply the upgrade by executing the following command:

	kubeadm upgrade apply 1.25.1-0 --allow-experimental-upgrades

_____________________________________________________________________


The table below shows the current state of component configs as understood by this version of kubeadm.
Configs that have a "yes" mark in the "MANUAL UPGRADE REQUIRED" column require manual config upgrade or
resetting to kubeadm defaults before a successful upgrade can be performed. The version to manually
upgrade to is denoted in the "PREFERRED VERSION" column.

API GROUP                 CURRENT VERSION   PREFERRED VERSION   MANUAL UPGRADE REQUIRED
kubeproxy.config.k8s.io   v1alpha1          v1alpha1            no
kubelet.config.k8s.io     v1beta1           v1beta1             no
_____________________________________________________________________


[upgrade/config] Making sure the configuration is correct:
[upgrade/config] Reading configuration from the cluster...
[upgrade/config] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
[preflight] Running pre-flight checks.
[upgrade] Running cluster health checks
[upgrade] Fetching available versions to upgrade to
[upgrade/versions] Cluster version: v1.25.0
[upgrade/versions] kubeadm version: v1.25.1
[upgrade/versions] Target version: 1.25.1-0
[upgrade/versions] Latest version in the v1.25 series: 1.25.1-0

Components that must be upgraded manually after you have upgraded the control plane with 'kubeadm upgrade apply':
COMPONENT   CURRENT       TARGET
kubelet     4 x v1.25.0   1.25.1-0

Upgrade to the latest version in the v1.25 series:

COMPONENT                 CURRENT   TARGET
kube-apiserver            v1.25.0   1.25.1-0
kube-controller-manager   v1.25.0   1.25.1-0
kube-scheduler            v1.25.0   1.25.1-0
kube-proxy                v1.25.0   1.25.1-0
CoreDNS                   v1.9.3    v1.9.3
etcd                      3.5.4-0   3.5.4-0

You can now apply the upgrade by executing the following command:

	kubeadm upgrade apply 1.25.1-0 --allow-experimental-upgrades

_____________________________________________________________________


The table below shows the current state of component configs as understood by this version of kubeadm.
Configs that have a "yes" mark in the "MANUAL UPGRADE REQUIRED" column require manual config upgrade or
resetting to kubeadm defaults before a successful upgrade can be performed. The version to manually
upgrade to is denoted in the "PREFERRED VERSION" column.

API GROUP                 CURRENT VERSION   PREFERRED VERSION   MANUAL UPGRADE REQUIRED
kubeproxy.config.k8s.io   v1alpha1          v1alpha1            no
kubelet.config.k8s.io     v1beta1           v1beta1             no
_____________________________________________________________________


5  根据提示进行下一步操作:
kubeadm upgrade apply v1.25.1

[root@k8s-master-1 ~]# kubeadm upgrade apply 1.25.1
[upgrade/config] Making sure the configuration is correct:
[upgrade/config] Reading configuration from the cluster...
[upgrade/config] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
[preflight] Running pre-flight checks.
[upgrade] Running cluster health checks
[upgrade/version] You have chosen to change the cluster version to "v1.25.1"
[upgrade/versions] Cluster version: v1.25.0
[upgrade/versions] kubeadm version: v1.25.1
[upgrade] Are you sure you want to proceed? [y/N]: y
[upgrade/prepull] Pulling images required for setting up a Kubernetes cluster
......
[addons] Applied essential addon: CoreDNS
[addons] Applied essential addon: kube-proxy

[upgrade/successful] SUCCESS! Your cluster was upgraded to "v1.25.1". Enjoy!

[upgrade/kubelet] Now that your control plane is upgraded, please proceed with upgrading your kubelets if you haven't already done so.


6 升级kubectl 和 kubelet:
yum install kubectl-1.25.1 kubelet-1.25.1 -y

[root@k8s-master-1 ~]# yum install kubectl-1.25.1 kubelet-1.25.1 -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package kubectl.x86_64 0:1.25.0-0 will be updated
---> Package kubectl.x86_64 0:1.25.1-0 will be an update
---> Package kubelet.x86_64 0:1.25.0-0 will be updated
---> Package kubelet.x86_64 0:1.25.1-0 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================================================================================================================
 Package                                                      Arch                                                        Version                                                        Repository                                                       Size
===============================================================================================================================================================================================================================================================
Updating:
 kubectl                                                      x86_64                                                      1.25.1-0                                                       kubernetes                                                       10 M
 kubelet                                                      x86_64                                                      1.25.1-0                                                       kubernetes                                                       21 M

Transaction Summary
===============================================================================================================================================================================================================================================================
Upgrade  2 Packages

Total download size: 31 M
Is this ok [y/d/N]: 


7 重启kubelet:
systemctl daemon-reload
systemctl restart kubelet

8  取消不可调度,重新上线:
kubectl uncordon k8s-master-1


[root@k8s-master-1 ~]# systemctl daemon-reload
[root@k8s-master-1 ~]# systemctl restart kubelet
[root@k8s-master-1 ~]# kubectl uncordon k8s-master-1
node/k8s-master-1 uncordoned

[root@k8s-master-1 ~]# kubectl get node -o wide
NAME           STATUS   ROLES           AGE   VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE                KERNEL-VERSION           CONTAINER-RUNTIME
k8s-master-1   Ready    control-plane   39d   v1.25.1   192.168.3.101   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-1     Ready    <none>          39d   v1.25.0   192.168.3.104   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-2     Ready    <none>          39d   v1.25.0   192.168.3.105   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-3     Ready    <none>          39d   v1.25.0   192.168.3.106   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21

升级工作节点(k8s-node-3):

1 升级kubeadm:
yum  install -y kubeadm-1.25.1


2 驱逐Node节点上的pod,且不可调度:
kubectl drain k8s-node-3 --ignore-daemonsets

[root@k8s-master-1 ~]# kubectl get node -o wide
NAME           STATUS                     ROLES           AGE   VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE                KERNEL-VERSION           CONTAINER-RUNTIME
k8s-master-1   Ready                      control-plane   39d   v1.25.1   192.168.3.101   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-1     Ready                      <none>          39d   v1.25.0   192.168.3.104   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-2     Ready                      <none>          39d   v1.25.0   192.168.3.105   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-3     Ready,SchedulingDisabled   <none>          39d   v1.25.0   192.168.3.106   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21

3 升级kubelet:
kubeadm upgrade node

4 升级kubectl 和 kubelet
[root@k8s-node-3 ~]# yum install kubectl-1.25.1 kubelet-1.25.1 -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package kubectl.x86_64 0:1.25.0-0 will be updated
---> Package kubectl.x86_64 0:1.25.1-0 will be an update
---> Package kubelet.x86_64 0:1.25.0-0 will be updated
---> Package kubelet.x86_64 0:1.25.1-0 will be an update
--> Finished Dependency Resolution
.......

5 重启kubelet:
[root@k8s-node-3 ~]# systemctl daemon-reload
[root@k8s-node-3 ~]# systemctl restart kubelet

6 取消不可调度,重新上线
[root@k8s-node-3 ~]# systemctl restart kubelet

7 master上查看结果:

[root@k8s-master-1 ~]# kubectl get node -o wide
NAME           STATUS   ROLES           AGE   VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE                KERNEL-VERSION           CONTAINER-RUNTIME
k8s-master-1   Ready    control-plane   39d   v1.25.1   192.168.3.101   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-1     Ready    <none>          39d   v1.25.0   192.168.3.104   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-2     Ready    <none>          39d   v1.25.0   192.168.3.105   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-3     Ready    <none>          39d   v1.25.1   192.168.3.106   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
posted @ 2023-01-02 23:34  风满楼9527  阅读(27)  评论(0编辑  收藏  举报