Upgrade the k8s cluster deployed by kubeadm

Upgrade the k8s cluster deployed by kubeadm

Master K's DevOps perspective

Upgrade k8s cluster


Using kubeadm to deploy a kubernetes cluster introduces the use of kubeadm to quickly deploy a k8s cluster. This article will upgrade the k8s cluster.

This upgrade method is only applicable to k8s clusters deployed with kubeadm.

Upgrade kubeadm


To upgrade the k8s cluster, you must first upgrade the kubeadm version to the version to be upgraded. That is, to upgrade the k8s-level group deployed by kubeadm, you must first upgrade the kubeadm version.


# kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.2", GitCommit:"59603c6e503c87169aea6106f57b9f242f64df89", GitTreeState:"clean", BuildDate:"2020-01-18T23:27:49Z", GoVersion:"go1.13.5", Compiler:"gc", Platform:"linux/amd64"}

Upgrade each master to the target version kubeadm


  • Upgrade kubeadm

# apt-cache madison kubeadm
# apt-get install kubeadm=1.17.4-00
# kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.4", GitCommit:"8d8aa39598534325ad77120c120a22b3a990b5ea", GitTreeState:"clean", BuildDate:"2020-03-12T21:01:11Z", GoVersion:"go1.13.8", Compiler:"gc", Platform:"linux/amd64"}
  • View upgrade plan

# 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.17.2
[upgrade/versions] kubeadm version: v1.17.4
I0723 15:10:34.814329   40861 version.go:251] remote version is much newer: v1.18.6; falling back to: stable-1.17
[upgrade/versions] Latest stable version: v1.17.9
[upgrade/versions] Latest version in the v1.17 series: v1.17.9

Components that must be upgraded manually after you have upgraded the control plane with 'kubeadm upgrade apply':
COMPONENT   CURRENT       AVAILABLE
Kubelet     6 x v1.17.2   v1.17.9

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

COMPONENT            CURRENT   AVAILABLE
API Server           v1.17.2   v1.17.9
Controller Manager   v1.17.2   v1.17.9
Scheduler            v1.17.2   v1.17.9
Kube Proxy           v1.17.2   v1.17.9
CoreDNS              1.6.5     1.6.5
Etcd                 3.4.3     3.4.3-0

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

        kubeadm upgrade apply v1.17.9

Note: Before you can perform this upgrade, you have to update kubeadm to v1.17.9.

Upgrade master

Upgrade each master node. The
master nodes must be upgraded one by one, not at the same time.


# kubeadm upgrade apply v1.17.4
......
[upgrade/successful] SUCCESS! Your cluster was upgraded to "v1.17.4". Enjoy!

[upgrade/kubelet] Now that your control plane is upgraded, please proceed with upgrading your kubelets if you haven't already done so.
# docker images|grep v1.17.4
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy                v1.17.4             6dec7cfde1e5        4 months ago        116MB
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver            v1.17.4             2e1ba57fe95a        4 months ago        171MB
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager   v1.17.4             7f997fcf3e94        4 months ago        161MB
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler            v1.17.4

Upgrade kubelet and kubectl


# apt install kubelet=1.17.4-00 kubectl=1.17.4-00

Upgrade node node


View the current node version


# kubectl get node
NAME          STATUS   ROLES    AGE   VERSION
k8s-master1   Ready    master   25h   v1.17.4
k8s-master2   Ready    master   24h   v1.17.4
k8s-master3   Ready    master   24h   v1.17.4
k8s-node1     Ready    <none>   23h   v1.17.2
k8s-node2     Ready    <none>   23h   v1.17.2
k8s-node3     Ready    <none>   23h   v1.17.2

Upgrade node configuration file


# kubeadm upgrade node --kubelet-version 1.17.4
[upgrade] Reading configuration from the cluster...
[upgrade] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'
[upgrade] Skipping phase. Not a control plane node.
[upgrade] Using kubelet config version 1.17.4, while kubernetes-version is v1.17.4
[kubelet-start] Downloading configuration for the kubelet from the "kubelet-config-1.17" ConfigMap in the kube-system namespace
[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.

Upgrade the kubelet and kubeadm of the node node


# apt install kubelet=1.17.4-00 kubeadm=1.17.4-00

View node


# kubectl get node
NAME          STATUS   ROLES    AGE   VERSION
k8s-master1   Ready    master   25h   v1.17.4
k8s-master2   Ready    master   24h   v1.17.4
k8s-master3   Ready    master   24h   v1.17.4
k8s-node1     Ready    <none>   24h   v1.17.4
k8s-node2     Ready    <none>   24h   v1.17.4
k8s-node3     Ready    <none>   24h   v1.17.4

Guess you like

Origin blog.51cto.com/15127511/2657644