Upgrading kubeadm clusters from v1.14 to v1.18

by Anish

Posted on Thursday April 23, 2020

Referefce

This page explains how to upgrade a Kubernetes cluster created with kubeadm from version 1.14.x to version 1.15.x, and from version 1.15.x to 1.18.y

The upgrade workflow at high level is the following:

  1. Upgrade the primary control plane node.
  2. Upgrade additional control plane nodes.
  3. Upgrade worker nodes.

The Setup

The kubernetes cluster is running with 1- Master and 1 Worker node with the v1.14.0 our traget is get this cluster to v1.18.2 version. The enviroment is running on ubuntu platform, for centos family only the repository will chnage the concept will remain the same.

master $ kubectl get nodes
NAME     STATUS   ROLES    AGE   VERSION
master   Ready    master   73m   v1.14.0
node01   Ready    <none>   72m   v1.14.0
master $ kubectl version
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.0", GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5", GitTreeState:"clean", BuildDate:"2019-03-25T15:53:57Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.0", GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5", GitTreeState:"clean", BuildDate:"2019-03-25T15:45:25Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}
master $ kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.0", GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5", GitTreeState:"clean", BuildDate:"2019-03-25T15:51:21Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}
master $
node01 $ kubectl version
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.0", GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5", GitTreeState:"clean", BuildDate:"2019-03-25T15:53:57Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?
node01 $ kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.0", GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5", GitTreeState:"clean", BuildDate:"2019-03-25T15:51:21Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}
node01 $

v1.14.x-v.1.15.x

Master Node - upgrade kubeadm

apt-mark unhold kubeadm && \
apt-get update && apt-get install -y kubeadm=1.15.11-00 && \
apt-mark hold kubeadm
kubeadm upgrade plan
kubeadm upgrade apply v1.15.11

Master Node - upgrade kubelet

apt-mark unhold kubelet kubectl && \
apt-get update && apt-get install -y kubelet=1.15.11-00 kubectl=1.15.11-00 && \
apt-mark hold kubelet kubectl
systemctl restart kubelet

Worker Node

Master Node - drain the Worker Node

kubectl drain node01 --ignore-daemonsets --delete-local-data

Worker Node - upgrade kubelet

apt-mark unhold kubelet kubectl && \
apt-get update && apt-get install -y kubelet=1.15.11-00 kubectl=1.15.11-00 && \
apt-mark hold kubelet kubectl
systemctl restart kubelet

Master Node - uncordon the Worker Node

kubectl uncordon node01

v1.15.x-v.1.16.x

Master Node - upgrade kubeadm

apt-mark unhold kubeadm && \
apt-get update && apt-get install -y kubeadm=1.16.9-00 && \
apt-mark hold kubeadm
kubeadm upgrade plan
kubeadm upgrade apply v1.16.9

Master Node - upgrade kubectl

apt-mark unhold kubelet kubectl && \
apt-get update && apt-get install -y kubelet=1.16.9-00 kubectl=1.16.9-00 && \
apt-mark hold kubelet kubectl
systemctl restart kubelet

Worker Node

Master Node - drain the Worker Node

kubectl drain node01 --ignore-daemonsets --delete-local-data

Worker Node - upgrade kubeadm

apt-mark unhold kubelet kubectl && \
apt-get update && apt-get install -y kubeadm=1.16.9-00 kubeadm=1.16.9-00 && \
apt-mark hold kubelet kubectl
kubeadm upgrade node

Worker Node - upgrade kubelet

apt-mark unhold kubelet kubectl && \
apt-get update && apt-get install -y kubelet=1.16.9-00 kubectl=1.16.9-00 && \
apt-mark hold kubelet kubectl
systemctl restart kubelet

Master Node - uncordon the Worker Node

kubectl uncordon node01

v1.16.x-v.1.17.x

Master Node - upgrade kubeadm

apt-mark unhold kubeadm && \
apt-get update && apt-get install -y kubeadm=1.17.5-00 && \
apt-mark hold kubeadm
# since apt-get version 1.1 you can also use the following method
apt-get update && \
apt-get install -y --allow-change-held-packages kubeadm=1.17.5-00
kubeadm upgrade plan
kubeadm upgrade apply v1.17.5

Master Node - upgrade kubectl

apt-mark unhold kubelet kubectl && \
apt-get update && apt-get install -y kubelet=1.17.5-00 kubectl=1.17.5-00 && \
apt-mark hold kubelet kubectl
systemctl restart kubelet

Worker Node

Master Node - drain the Worker Node

kubectl drain node01 --ignore-daemonsets --delete-local-data
# replace x in 1.17.x-00 with the latest patch version
apt-mark unhold kubeadm && \
apt-get update && apt-get install -y kubeadm=1.17.5-00 && \
apt-mark hold kubeadm 
# since apt-get version 1.1 you can also use the following method
apt-get update && \
apt-get install -y --allow-change-held-packages kubeadm=1.17.5-00

Worker Node - upgrade kubeadm

# since apt-get version 1.1 you can also use the following method
apt-get update && \
apt-get install -y --allow-change-held-packages kubeadm=1.17.5-00
kubeadm upgrade node

Worker Node - upgrade kubectl

# replace x in 1.17.x-00 with the latest patch version
apt-mark unhold kubelet kubectl && \
apt-get update && apt-get install -y kubelet=1.17.5-00 kubectl=1.17.5-00 && \
apt-mark hold kubelet kubectl
# since apt-get version 1.1 you can also use the following method
apt-get update && \
apt-get install -y --allow-change-held-packages kubelet=1.17.5-00 kubectl=1.17.5-00
systemctl restart kubelet

Master Node - uncordon the Worker Node

kubectl uncordon node01

v1.17.x-v.1.18.x

Master Node - upgrade kubeadm

apt-mark unhold kubeadm && \
apt-get update && apt-get install -y kubeadm=1.18.2-00 && \
apt-mark hold kubeadm
# since apt-get version 1.1 you can also use the following method
apt-get update && \
apt-get install -y --allow-change-held-packages kubeadm=1.18.2-00
kubeadm upgrade plan
kubeadm upgrade apply v1.18.2

Master Node - upgrade kubectl

# replace x in 1.18.x-00 with the latest patch version
apt-mark unhold kubelet kubectl && \
apt-get update && apt-get install -y kubelet=1.18.2-00 kubectl=1.18.2-00 && \
apt-mark hold kubelet kubectl
# since apt-get version 1.1 you can also use the following method
apt-get update && \
apt-get install -y --allow-change-held-packages kubelet=1.18.2-00 kubectl=1.18.2-00
systemctl restart kubelet

Worker Node

Master Node - drain the Worker Node

kubectl drain node01 --ignore-daemonsets --delete-local-data

Worker Node - upgrade kubeadm

apt-mark unhold kubeadm && \
apt-get update && apt-get install -y kubeadm=1.18.2-00 && \
apt-mark hold kubeadm

Worker Node - upgrade kubectl

apt-mark unhold kubelet kubectl && \
apt-get update && apt-get install -y kubelet=1.18.2-00 kubectl=1.18.2-00 && \
apt-mark hold kubelet kubectl
systemctl restart kubelet

Master Node - uncordon the Worker Node

kubectl uncordon node01

since it's kubernetes you may encounter some issues, feel free to poke me

Video Demo for Ubuntu v1.14-v1.18

Video Demo for RHEL


Thanku for reading !!! Give a Share for Support


Your Support Matters!

Instead of directly asking for donations, I'm thrilled to offer you all nine of my books for just $9 on leanpub By grabbing this bundle you not only help cover my coffee, beer, and Amazon bills but also play a crucial role in advancing and refining this project. Your contribution is indispensable, and I'm genuinely grateful for your involvement in this journey!

Any private key value that you enter or we generate is not stored on this site, this tool is provided via an HTTPS URL to ensure that private keys cannot be stolen, for extra security run this software on your network, no cloud dependency




python Cryptography Topics
Topics
For Coffee/ Beer/ Amazon Bill and further development of the project Support by Purchasing, The Modern Cryptography CookBook for Just $9 Coupon Price

Kubernetes for DevOps

Hello Dockerfile

Cryptography for Python Developers

Cryptography for JavaScript Developers

Go lang ryptography for Developers

Here