How to upgrade Kubernetes Cluster and back-up the etcd

Mustafa AK
Clarusway
Published in
3 min readJun 22, 2021

--

In this article, we will focus on how we can update our Kubernetes Cluster. In this scenario, we have a Kubernetes cluster that consists of one ControlPlane and one WorkerNode, which is called node01.

First of all, we check our cluster nodes and their versions.

kubectl get nodes -o wide

We get now our nodes and their versions are both v1.18.00

Now, we can start updating our control plane first. We update our control plane using the below commands.

apt-get update && apt-get install -y kubeadm=1.19.0-00apt-get update && apt-get install -y kubelet=1.19.0-00 kubectl=1.19.0-00sudo systemctl daemon-reloadsudo systemctl restart kubelet

We have updated our control plane to version v1.19.0, and we should update the worker node now. But we have to evict all deployments to the control plane, so we have to drain our worker node.

kubectl drain node01

After draining the node, we should connect node01 using ssh, then we can update our node01 to version v1.19.0 using the below command.

ssh node01apt-get upgrade -y kubeadm=1.12.0-00

apt-get upgrade -y kubelet=1.12.0-00

kubeadm upgrade node1 config --kubelet-version v1.12.0

systemctl restart kubelet

Now we have updated our worker node. We should switch to the control plane and uncordon the node01 using the below command.

kubectl uncordon node01

We have successfully updated our cluster and now we can back up the etcd using the below command.

export ETCDCTL_API=3etcdctl --endpoints=https://[127.0.0.1]:2379 \
--cacert=/etc/kubernetes/pki/etcd/ca.crt \
--cert=/etc/kubernetes/pki/etcd/server.crt \
--key=/etc/kubernetes/pki/etcd/server.key \
snapshot save /opt/etcd-backup.db

Finally, we have backed up the etcd to a specific directory.

Reference: https://v1-19.docs.kubernetes.io/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade/

--

--

Mustafa AK
Clarusway

DevOps Engineer @ relayr | 2 x AWS and 2 x Azure Certified Cloud Engineer | Terraform | CKA | CKAD