k8s版本升级步骤
k8s版本升级是一项复杂的操作,需要小心地执行,以免出现意外错误。以下是从k8s 1.15升级到k8s 1.16的步骤:
步骤1:安装升级版本的kubeadm
在master节点上,使用以下命令安装升级版本的kubeadm:
`[root@k8s-16-101 ~]# yum install -y kubeadm-1.16.0-0 --disableexcludes=kubernetes`
步骤2:验证升级后的版本
使用以下命令验证升级后的版本:
`[root@k8s-16-101 ~]# kubeadm version`
输出结果:
`kubeadm version: &version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.0", GitCommit:"2bd9643cee5b3b3a5ecbd3af49d09018f0773c77", GitTreeState:"clean", BuildDate:"2019-09-18T14:34:01Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}`
步骤3:列出升级前的版本和要升级后的版本差别
使用以下命令列出升级前的版本和要升级后的版本差别:
`[root@k8s-16-101 ~]# 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 -oyaml'
[preflight] Running pre-flight checks.
[upgrade] Making sure the cluster is healthy:
[upgrade] Fetching available versions to upgrade to
[upgrade/versions] Cluster version: v1.15.10
[upgrade/versions] kubeadm version: v1.15.10
I0225 16:58:23.930065 318 version.go:251] remote version is much newer: v1.20.4; falling back to: stable-1.16
[upgrade/versions] Latest stable version: v1.16.0
W0225 16:58:43.695627 318 version.go:101] could not fetch a Kubernetes version from the internet: unable to get URL "https://dl.k8s.io/release/stable-1.16.txt": Get https://storage.googleapis.com/kubernetes-release/release/stable-1.16.txt: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
W0225 16:58:43.695801 318 version.go:102] falling back to the local client version: v1.15.10
[upgrade/versions] Latest version in the v1.15 series: v1.15.10
Components that must be upgraded manually after you have upgraded the control plane with 'kubeadm upgrade apply':
COMPONENT CURRENT AVAILABLE
Kubelet 3 x v1.15.10 v1.16.0
Upgrade to the latest version in the v1.15 series:
COMPONENT CURRENT AVAILABLE
API Server v1.15.10 v1.16.0
Controller Manager v1.15.10 v1.16.0
Scheduler v1.15.10 v1.16.0`
从上面的输出结果可以看到,当前的k8s版本是v1.15.10,最新的稳定版本是v1.16.0。同时,输出结果还显示了需要手动升级的组件,包括Kubelet、API Server、Controller Manager和Scheduler。
k8s版本升级需要小心地执行,每一步骤都需要认真地执行,以免出现意外错误。同时,需要仔细地检查升级前的版本和要升级后的版本差别,以免出现版本不兼容的问题。