Kubernetes V1.22.4升级到1.23.0

一、首先更新下yum缓存
yum clean all
yum makecache
二、yum list 查一下最新的稳定版本
yum list --showduplicates kubeadm --disableexcludes=kubernetes
三、升级master
3.1、kubeadm 升级
yum install -y kubeadm-1.23.0 --disableexcludes=kubernetes
3.2、验证kubeadm 版本
kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.0", GitCommit:"ab69524f795c42094a6630298ff53f3c3ebab7f4", GitTreeState:"clean", BuildDate:"2021-12-07T18:15:11Z", GoVersion:"go1.17.3", Compiler:"gc", Platform:"linux/amd64"}
3.3、排空master节点
kubectl drain k8s-master --ignore-daemonsets
3.4、验证升级计划
kubeadm upgrade plan
[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.22.4
[upgrade/versions] kubeadm version: v1.23.0
[upgrade/versions] Target version: v1.23.3
[upgrade/versions] Latest version in the v1.22 series: v1.22.6
Components that must be upgraded manually after you have upgraded the control plane with 'kubeadm upgrade apply':
COMPONENT CURRENT TARGET
kubelet 3 x v1.22.4 v1.22.6
Upgrade to the latest version in the v1.22 series:
COMPONENT CURRENT TARGET
kube-apiserver v1.22.4 v1.22.6
kube-controller-manager v1.22.4 v1.22.6
kube-scheduler v1.22.4 v1.22.6
kube-proxy v1.22.4 v1.22.6
CoreDNS v1.8.4 v1.8.6
etcd 3.5.0-0 3.5.1-0
You can now apply the upgrade by executing the following command:
kubeadm upgrade apply v1.22.6
_____________________________________________________________________
Components that must be upgraded manually after you have upgraded the control plane with 'kubeadm upgrade apply':
COMPONENT CURRENT TARGET
kubelet 3 x v1.22.4 v1.23.3
Upgrade to the latest stable version:
COMPONENT CURRENT TARGET
kube-apiserver v1.22.4 v1.23.3
kube-controller-manager v1.22.4 v1.23.3
kube-scheduler v1.22.4 v1.23.3
kube-proxy v1.22.4 v1.23.3
CoreDNS v1.8.4 v1.8.6
etcd 3.5.0-0 3.5.1-0
You can now apply the upgrade by executing the following command:
kubeadm upgrade apply v1.23.3
Note: Before you can perform this upgrade, you have to update kubeadm to v1.23.3.
_____________________________________________________________________
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
_____________________________________________________________________
[root@k8s-master ~]#
3.5、选择要升级到的目标版本

如果不是第一个升级的master的话执行:kubeadm upgrade node

只有第一个升级的master执行:kubeadm upgrade apply操作

[root@k8s-master ~]# kubeadm upgrade apply v1.23.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/version] You have chosen to change the cluster version to "v1.23.0"
[upgrade/versions] Cluster version: v1.22.4
[upgrade/versions] kubeadm version: v1.23.0
[upgrade/confirm] Are you sure you want to proceed with the upgrade? [y/N]: y
[upgrade/prepull] Pulling images required for setting up a Kubernetes cluster
[upgrade/prepull] This might take a minute or two, depending on the speed of your internet connection
[upgrade/prepull] You can also perform this action in beforehand using 'kubeadm config images pull'
[upgrade/apply] Upgrading your Static Pod-hosted control plane to version "v1.23.0"...
Static pod: kube-apiserver-k8s-master hash: d3452b28e1fb9eb366cdbab36a7e88b2
Static pod: kube-controller-manager-k8s-master hash: 70395e6e769fd867813b902c45bece19
Static pod: kube-scheduler-k8s-master hash: ac2d970537ef80a81b00daf235de18e5
[upgrade/etcd] Upgrading to TLS for etcd
Static pod: etcd-k8s-master hash: e991ddf14a7b90b4e7430ec956ce1f5b
[upgrade/staticpods] Preparing for "etcd" upgrade
[upgrade/staticpods] Renewing etcd-server certificate
[upgrade/staticpods] Renewing etcd-peer certificate
[upgrade/staticpods] Renewing etcd-healthcheck-client certificate
[upgrade/staticpods] Moved new manifest to "/etc/kubernetes/manifests/etcd.yaml" and backed up old manifest to "/etc/kubernetes/tmp/kubeadm-backup-manifests-2022-02-10-15-09-44/etcd.yaml"
[upgrade/staticpods] Waiting for the kubelet to restart the component
[upgrade/staticpods] This might take a minute or longer depending on the component/version gap (timeout 5m0s)
Static pod: etcd-k8s-master hash: e991ddf14a7b90b4e7430ec956ce1f5b
Static pod: etcd-k8s-master hash: c5549d895cdd0282f7ccc5201c46dd12
[apiclient] Found 1 Pods for label selector component=etcd
[upgrade/staticpods] Component "etcd" upgraded successfully!
[upgrade/etcd] Waiting for etcd to become available
[upgrade/staticpods] Writing new Static Pod manifests to "/etc/kubernetes/tmp/kubeadm-upgraded-manifests698984810"
[upgrade/staticpods] Preparing for "kube-apiserver" upgrade
[upgrade/staticpods] Renewing apiserver certificate
[upgrade/staticpods] Renewing apiserver-kubelet-client certificate
[upgrade/staticpods] Renewing front-proxy-client certificate
[upgrade/staticpods] Renewing apiserver-etcd-client certificate
[upgrade/staticpods] Moved new manifest to "/etc/kubernetes/manifests/kube-apiserver.yaml" and backed up old manifest to "/etc/kubernetes/tmp/kubeadm-backup-manifests-2022-02-10-15-09-44/kube-apiserver.yaml"
[upgrade/staticpods] Waiting for the kubelet to restart the component
[upgrade/staticpods] This might take a minute or longer depending on the component/version gap (timeout 5m0s)
Static pod: kube-apiserver-k8s-master hash: d3452b28e1fb9eb366cdbab36a7e88b2
Static pod: kube-apiserver-k8s-master hash: 6da47145944290f7c38fa6d826eda641
[apiclient] Found 1 Pods for label selector component=kube-apiserver
[upgrade/staticpods] Component "kube-apiserver" upgraded successfully!
[upgrade/staticpods] Preparing for "kube-controller-manager" upgrade
[upgrade/staticpods] Renewing controller-manager.conf certificate
[upgrade/staticpods] Moved new manifest to "/etc/kubernetes/manifests/kube-controller-manager.yaml" and backed up old manifest to "/etc/kubernetes/tmp/kubeadm-backup-manifests-2022-02-10-15-09-44/kube-controller-manager.yaml"
[upgrade/staticpods] Waiting for the kubelet to restart the component
[upgrade/staticpods] This might take a minute or longer depending on the component/version gap (timeout 5m0s)
Static pod: kube-controller-manager-k8s-master hash: 70395e6e769fd867813b902c45bece19
Static pod: kube-controller-manager-k8s-master hash: 8f65b494d0302a9ea95b3fec24f83b05
[apiclient] Found 1 Pods for label selector component=kube-controller-manager
[upgrade/staticpods] Component "kube-controller-manager" upgraded successfully!
[upgrade/staticpods] Preparing for "kube-scheduler" upgrade
[upgrade/staticpods] Renewing scheduler.conf certificate
[upgrade/staticpods] Moved new manifest to "/etc/kubernetes/manifests/kube-scheduler.yaml" and backed up old manifest to "/etc/kubernetes/tmp/kubeadm-backup-manifests-2022-02-10-15-09-44/kube-scheduler.yaml"
[upgrade/staticpods] Waiting for the kubelet to restart the component
[upgrade/staticpods] This might take a minute or longer depending on the component/version gap (timeout 5m0s)
Static pod: kube-scheduler-k8s-master hash: ac2d970537ef80a81b00daf235de18e5
Static pod: kube-scheduler-k8s-master hash: 28dad46d170cdc91ae0b7de16a4ff238
[apiclient] Found 1 Pods for label selector component=kube-scheduler
[upgrade/staticpods] Component "kube-scheduler" upgraded successfully!
[upgrade/postupgrade] Applying label node-role.kubernetes.io/control-plane='' to Nodes with label node-role.kubernetes.io/master='' (deprecated)
[upload-config] Storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace
[kubelet] Creating a ConfigMap "kubelet-config-1.23" in namespace kube-system with the configuration for the kubelets in the cluster
NOTE: The "kubelet-config-1.23" naming of the kubelet ConfigMap is deprecated. Once the UnversionedKubeletConfigMap feature gate graduates to Beta the default name will become just "kubelet-config". Kubeadm upgrade will handle this transition transparently.
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[bootstrap-token] configured RBAC rules to allow Node Bootstrap tokens to get nodes
[bootstrap-token] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials
[bootstrap-token] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token
[bootstrap-token] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster
[addons] Applied essential addon: CoreDNS
[addons] Applied essential addon: kube-proxy
[upgrade/successful] SUCCESS! Your cluster was upgraded to "v1.23.0". Enjoy!
[upgrade/kubelet] Now that your control plane is upgraded, please proceed with upgrading your kubelets if you haven't already done so.
3.5、取消对控制面节点的保护
[root@k8s-master ~]# kubectl uncordon k8s-master
node/k8s-master uncordoned
3.6、升级 kubelet 和 kubectl
[root@k8s-master ~]# yum install -y kubelet-1.23.0 kubectl-1.23.0 --disableexcludes=kubernetes
重启 kubelet
[root@k8s-master ~]# systemctl daemon-reload
[root@k8s-master ~]# systemctl restart kubelet
四、升级工作节点(node节点)
4.1、升级 kubeadm
[root@k8s-node01 ~]# yum install -y kubeadm-1.23.0 --disableexcludes=kubernetes
4.2、保护节点
[root@k8s-master ~]# kubectl drain k8s-node01 --ignore-daemonsets
4.3、升级 kubelet 配置
[root@k8s-node01 ~]# kubeadm upgrade node
4.4、升级 kubelet 与 kubectl
[root@k8s-node01 ~]# yum install -y kubelet-1.23.0 kubectl-1.23.0 --disableexcludes=kubernetes
重启 kubelet
[root@k8s-master ~]# systemctl daemon-reload
[root@k8s-master ~]# systemctl restart kubelet
4.5、取消对节点的保护
[root@k8s-master ~]# kubectl uncordon k8s-node01
五、验证集群
[root@k8s-master ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master Ready control-plane,master 23d v1.23.0
k8s-node01 Ready,SchedulingDisabled <none> 23d v1.23.0
k8s-node02 Ready <none> 23d v1.23.0
posted @   一毛丶丶  阅读(276)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示