Kubernetes 1.12.1 quick upgrade

Kubernetes 1.12.1 quick upgrade includes three main steps: upgrade kubedm / kubectl / kubelet version, pull image, upgrade kubernetes cluster.

1. Upgrade kubeadm/kubectl/kubelet version

apt install kubeadm=1.12.1 kubectl=1.12.1 kubelet=1.12.1

To view the container image version of this version:

kubeadm config images list

The output is as follows:

~# kubeadm config images list

k8s.gcr.io/kube-apiserver:v1.12.1
k8s.gcr.io/kube-controller-manager:v1.12.1
k8s.gcr.io/kube-scheduler:v1.12.1
k8s.gcr.io/kube-proxy:v1.12.1
k8s.gcr.io/pause:3.1
k8s.gcr.io/etcd:3.2.24
k8s.gcr.io/coredns:1.2.2

2. Pull container image

I mirrored the image to the container warehouse of Alibaba cloud's Hangzhou computer room, and it's faster to pull it.

echo ""
echo "=========================================================="
echo "Pull Kubernetes v1.12.1 Images from aliyuncs.com ......"
echo "=========================================================="
echo ""

MY_REGISTRY=registry.cn-hangzhou.aliyuncs.com/openthings

## Pull mirror image
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-apiserver:v1.12.1
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-controller-manager:v1.12.1
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-scheduler:v1.12.1
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-proxy:v1.12.1
docker pull ${MY_REGISTRY}/k8s-gcr-io-etcd:3.2.24
docker pull ${MY_REGISTRY}/k8s-gcr-io-pause:3.1
docker pull ${MY_REGISTRY}/k8s-gcr-io-coredns:1.2.2


## Add Tag
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-apiserver:v1.12.1 k8s.gcr.io/kube-apiserver:v1.12.1
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-scheduler:v1.12.1 k8s.gcr.io/kube-scheduler:v1.12.1
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-controller-manager:v1.12.1 k8s.gcr.io/kube-controller-manager:v1.12.1
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-proxy:v1.12.1 k8s.gcr.io/kube-proxy:v1.12.1
docker tag ${MY_REGISTRY}/k8s-gcr-io-etcd:3.2.24 k8s.gcr.io/etcd:3.2.24
docker tag ${MY_REGISTRY}/k8s-gcr-io-pause:3.1 k8s.gcr.io/pause:3.1
docker tag ${MY_REGISTRY}/k8s-gcr-io-coredns:1.2.2 k8s.gcr.io/coredns:1.2.2

echo ""
echo "=========================================================="
echo "Pull Kubernetes v1.12.1 Images FINISHED."
echo "into registry.cn-hangzhou.aliyuncs.com/openthings, "
echo "           by openthings@https://my.oschina.net/u/2306127."
echo "=========================================================="

echo ""

Save as a shell script and execute.

3. Upgrade Kubernetes cluster

First, look at the versions of the components that need to be upgraded.

Using the kubeadm upgrade plan, the output version upgrade information is as follows:

COMPONENT            CURRENT   AVAILABLE
API Server           v1.11.2   v1.12.1
Controller Manager   v1.11.2   v1.12.1
Scheduler            v1.11.2   v1.12.1
Kube Proxy           v1.11.2   v1.12.1
CoreDNS              1.1.3     1.2.2
Etcd                 3.2.18    3.2.24

Make sure that the container image above has been downloaded (if it is not downloaded in advance, it may be blocked by the network and suspended), and then perform the upgrade:

kubeadm upgrade apply v1.12.1

See the following message, OK.

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

Keywords: Docker Kubernetes kubelet shell

Added by chetan1 on Thu, 19 Dec 2019 16:25:01 +0200