当前位置:网站首页>升级kubernetes 1.23.2到1.24.1
升级kubernetes 1.23.2到1.24.1
2022-07-17 00:16:00 【老段工作室】
前面讲了runtime如何由docker迁移到containerd,k8s 1.24相较于之前的版本一个重要的变化是已经废弃dockershim了,那么下面如何由1.23.2升级到1.24.1。
1.准备工作
修改两个节点的参数,下面的步骤应该在runtime迁移之后就做的。
[[email protected] ~]# kubectl edit nodes vms61.rhce.cc
把
apiVersion: v1
kind: Node
metadata:
annotations:
kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock
修改为
apiVersion: v1
kind: Node
metadata:
annotations:
kubeadm.alpha.kubernetes.io/cri-socket: /var/run/containerd/containerd.sock
[[email protected] ~]# kubectl edit nodes vms62.rhce.cc
做上面类似的修改,然后两台机器上重启kubelet
[[email protected] ~]# systemctl restart kubelet
[[email protected] ~]#
如果不改的话,再更新时会有如下报错。
[ERROR ImagePull]: failed to pull image registry.aliyuncs.com/google_containers/kube-apiserver:v1.24.1: output:
...输出... error: exit status 1
2.升级master
1.先安装kubeadm1.24.1
[[email protected] ~]# yum install -y kubeadm-1.24.1-0 --disableexcludes=kubernetes
...输出...
[[email protected] ~]#
2.腾空节点vms61
[[email protected] ~]# kubectl drain vms61.rhce.cc --ignore-daemonsets
node/vms61.rhce.cc cordoned
WARNING: ignoring DaemonSet-managed Pods: kube-system/calico-node-lf6t2, kube-system/kube-proxy-mhr5g
evicting pod kube-system/coredns-6d8c4cb4d-f2vq4
evicting pod kube-system/calico-kube-controllers-78d6f96c7b-wfx5b
evicting pod kube-system/coredns-6d8c4cb4d-clll2
pod/calico-kube-controllers-78d6f96c7b-wfx5b evicted
pod/coredns-6d8c4cb4d-clll2 evicted
pod/coredns-6d8c4cb4d-f2vq4 evicted
node/vms61.rhce.cc drained
[[email protected] ~]#
3.升级控制节点各组件
[[email protected] ~]# kubeadm upgrade apply v1.24.1
...输出..
[upgrade/successful] SUCCESS! Your cluster was upgraded to "v1.24.1". Enjoy!
[upgrade/kubelet] Now that your control plane is upgraded, please proceed with upgrading your kubelets if you haven't already done so.
[[email protected] ~]#
4.升级kubelet和kubectl到1.24.1
[[email protected] ~]# yum install -y kubelet-1.24.1-0 kubectl-1.24.1-0 --disableexcludes=kubernetes
[[email protected] ~]#
修改kubelet参数
由
[[email protected] ~]# cat /var/lib/kubelet/kubeadm-flags.env
KUBELET_KUBEADM_ARGS="--network-plugin=cni --pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.5"
[[email protected] ~]#
改为
[[email protected] ~]# cat /var/lib/kubelet/kubeadm-flags.env
KUBELET_KUBEADM_ARGS="--pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.5"
[[email protected] ~]#
即这里删除了参数–network-plugin=cni,如果不删除此参数则kubelet启动不了。
5.重启kubelet
[[email protected] ~]# systemctl daemon-reload; systemctl restart kubelet
[[email protected] ~]#
6.对vms61执行uncordon
[[email protected] ~]# kubectl uncordon vms61.rhce.cc
node/vms61.rhce.cc uncordoned
[[email protected] ~]#
查看节点状态。
[[email protected] ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
vms61.rhce.cc Ready control-plane 235d v1.24.1
vms62.rhce.cc Ready <none> 235d v1.23.2
[[email protected] ~]#
2.升级worker
1.在worker上安装kubeadm v1.24.1。
[[email protected] ~]# yum install -y kubeadm-1.24.1-0 --disableexcludes=kubernetes
[[email protected] ~]#
在master(vms61)上腾空节点vms62
[[email protected] ~]# kubectl drain vms62.rhce.cc --ignore-daemonsets
node/vms62.rhce.cc cordoned
WARNING: ignoring DaemonSet-managed Pods: kube-system/calico-node-hth7g, kube-system/kube-proxy-zdhtx
evicting pod kube-system/coredns-6d8c4cb4d-rzqfm
evicting pod default/web1-665f6b46cb-jgzp8
evicting pod kube-system/calico-kube-controllers-78d6f96c7b-8nfvs
evicting pod kube-system/coredns-6d8c4cb4d-mnjwm
evicting pod default/web1-665f6b46cb-fl9b4
pod/web1-665f6b46cb-jgzp8 evicted
pod/web1-665f6b46cb-fl9b4 evicted
pod/calico-kube-controllers-78d6f96c7b-8nfvs evicted
pod/coredns-6d8c4cb4d-rzqfm evicted
pod/coredns-6d8c4cb4d-mnjwm evicted
node/vms62.rhce.cc drained
[[email protected] ~]#
2.切换到vms62上升级kubelet配置
[[email protected] ~]# kubeadm upgrade node
[upgrade] Reading configuration from the cluster...
[upgrade] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
[preflight] Running pre-flight checks
[preflight] Skipping prepull. Not a control plane node.
[upgrade] Skipping phase. Not a control plane node.
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[upgrade] The configuration for this node was successfully updated!
[upgrade] Now you should go ahead and upgrade the kubelet package using your package manager.
[[email protected] ~]#
修改kubelet的变量文件,由
[[email protected] ~]# cat /var/lib/kubelet/kubeadm-flags.env
KUBELET_KUBEADM_ARGS="--network-plugin=cni --pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.5"
[[email protected] ~]#
改为
[[email protected] ~]# cat /var/lib/kubelet/kubeadm-flags.env
KUBELET_KUBEADM_ARGS="--pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.5"
[[email protected] ~]#
即这里删除了参数–network-plugin=cni 。
3.升级kubelet和kubectl
[[email protected] ~]# yum install -y kubelet-1.24.1-0 kubectl-1.24.1-0 --disableexcludes=kubernetes
[[email protected] ~]#
4.重启kubelet
[[email protected] ~]# systemctl daemon-reload; systemctl restart kubelet
5.解除对vms62的保护
切换到vms61对vms62执行uncordon操作
[[email protected] ~]# kubectl uncordon vms62.rhce.cc
node/vms62.rhce.cc uncordoned
[[email protected] ~]#
3.验证
查看节点状态
[[email protected] ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
vms61.rhce.cc Ready control-plane 235d v1.24.1
vms62.rhce.cc Ready <none> 235d v1.24.1
[[email protected] ~]#
查看pod
[[email protected] ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
web1-665f6b46cb-g9kcl 1/1 Running 0 4m46s
web1-665f6b46cb-q8db5 1/1 Running 0 4m47s
[[email protected] ~]#
边栏推荐
- Inverse yuan (I'll add these words if there are too many people using the name)
- How to use nmon
- Echo -e usage
- InnoDB, MySQL structure, and the difference between the three kinds of deletion
- Lamp platform deployment and Application
- No, no, No. yesterday, someone really didn't write binary enumeration
- 正则、扩展表达式,sed文本处理器与awk工具、用脚本改IP地址
- Response assertion of JMeter interface test
- Use JMeter to test services based on websocket protocol
- Dirty reading, unreal reading, non repeatable reading
猜你喜欢

安装.NET提示“无法建立到信任根颁发机构的证书链”(方法简单有下载地址)

Network layer protocol and IP packet format (detailed)

How to add software shortcuts to the right mouse button list

A preliminary study of MySQL

In depth performance test data analysis

Sword finger offer 48 The longest substring without repeated characters

RIP综合实验

echo -e用法

ctfhub--ssrf

Understand HTTP cache in 30 minutes
随机推荐
Services for NFS
时间管理方法的反思与探讨
MySQL差删改查用户登录修改密码
echo -e用法
Performance bottleneck positioning XMIND
Network layer protocol and IP packet format (detailed)
Network layer transmission protocol (detailed)
Post man JSON script to JMX script of JMeter
HCIA_RIP实验
Test points of login function
MySQL differential deletion and modification check user login and password modification
Find() (if the name is used by too many people, I will add words)
单片机之数码管秒表的动态显示
ENSP静态路由实验
Sword finger offer 53 - I. find the number I in the sorted array
Getting to know Alibaba cloud environment construction for the first time: unable to connect remotely, and having been in the pit: the server Ping fails, FTP is built, the server builds the database,
Keep two decimal places and take values upward
Mysql database installation
Static routing (detailed)
shell脚本之循环语句与函数