Kubernetes 1.17.4 quick upgrade

Keywords: Kubernetes Docker kubelet sudo

Kubernetes 1.17.4 has been officially released, and it can also be upgraded directly for highly available clusters. The quick upgrade (including the quick download link of domestic image) includes three main steps: upgrading the kubeadm/kubectl/kubelet version, pulling the image, and upgrading the kubernetes cluster. Reference The software lock version on Ubuntu is not updated >Install a specific DockerCE version.

1. Upgrade kubeadm/kubectl/kubelet version

sudo apt install kubeadm=1.17.4-00 kubectl=1.17.4-00 kubelet=1.17.4-00

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.17.4
k8s.gcr.io/kube-controller-manager:v1.17.4
k8s.gcr.io/kube-scheduler:v1.17.4
k8s.gcr.io/kube-proxy:v1.17.4
k8s.gcr.io/pause:3.1
k8s.gcr.io/etcd:3.4.3-0
k8s.gcr.io/coredns:1.6.5

2. Pull container image

The original kubernetes image file is on gcr and cannot be downloaded directly. 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.17.4 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.17.4
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-controller-manager:v1.17.4
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-scheduler:v1.17.4
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-proxy:v1.17.4
docker pull ${MY_REGISTRY}/k8s-gcr-io-etcd:3.4.3-0
docker pull ${MY_REGISTRY}/k8s-gcr-io-pause:3.1
docker pull ${MY_REGISTRY}/k8s-gcr-io-coredns:1.6.5

## Add Tag
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-apiserver:v1.17.4 k8s.gcr.io/kube-apiserver:v1.17.4
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-scheduler:v1.17.4 k8s.gcr.io/kube-scheduler:v1.17.4
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-controller-manager:v1.17.4 k8s.gcr.io/kube-controller-manager:v1.17.4
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-proxy:v1.17.4 k8s.gcr.io/kube-proxy:v1.17.4
docker tag ${MY_REGISTRY}/k8s-gcr-io-etcd:3.4.3-0 k8s.gcr.io/etcd:3.4.3-0
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.6.5 k8s.gcr.io/coredns:1.6.5

echo ""
echo "=========================================================="
echo "Pull Kubernetes v1.17.4 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

New installation:

#Specify IP address, version 1.17.4:
sudo kubeadm init --kubernetes-version=v1.17.4 --apiserver-advertise-address=10.1.1.199 --pod-network-cidr=10.244.0.0/16

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:

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

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

COMPONENT            CURRENT   AVAILABLE
API Server           v1.17.2   v1.17.4
Controller Manager   v1.17.2   v1.17.4
Scheduler            v1.17.2   v1.17.4
Kube Proxy           v1.17.2   v1.17.4
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.4

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.17.4

See the following message, OK.

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

Then, configure the current user environment:

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

You can use kubectl version to view the status and kubectl cluster info to view the service address.

4. Upgrade of work nodes

Each work node needs to pull the image of the corresponding version above and install the corresponding version of kubelet.

Check version:

~$ kubectl version

To view Pod information:

kubectl get pod --all-namespaces

Done.

Further reference:

Posted by jonah on Wed, 18 Mar 2020 09:28:32 -0700