Get to Know How to Upgrade a Kubernetes Cluster - Part 1

ยท

3 min read

Get to Know How to Upgrade a Kubernetes Cluster - Part 1

Hello DevOps enthusiasts ๐Ÿ˜ƒ !

Today Lets learn the importance of knowing kubernetes upgrading process and steps.

Kubernetes comes with new version for every 3 months. We as a DevOps engineers, we should know how to upgrade cluster with zero downtime as this activity is a frequent one.

In an organization, DevOps engineers maintains different clusters like Unit, Test, Stage, Pre, Prod etc.

As users uses prod environment, we should make sure prod is not impacted with our upgradation. Hence we test prior with different lower stage clusters.

Without further delay, lets jump into further steps.

Upgrading cluster correctly is very important to know and if any mistake is done it cant be irreversible.

Here are pre-requisites that you should know before directly upgrading:

Prerequisites

  1. Cordon Nodes

In Kubernetes, cordoning a node refers to the action of marking a node as unschedulable, meaning no new pods will be scheduled on that node, but the existing pods continue to run without disruptions.

  1. Understanding change logs and release notes

    It is crucial for ensuring smooth system upgrades and maintaining stability. These documents track updates, detailing new features, bug fixes, and improvements, which helps teams stay informed about changes. For example: If a new change uses new feature, you should not get confused why it is not working with previous one. ๐Ÿค”

  2. Irreversible

For Example : Your current cluster is 1.30 and you upgraded to 1.31. If you want to undo the process, it is not possible as this is irreversible process. You should do fresh start in that case which impacts the product deployment.

Hence it is better to test first in lower environments, and then go with prod.

Start with low level env โ€”> Stage env โ€”> pre prod โ€”> Prod ( Bteer to maintain gap of one week between lower envs to prod to understand smooth upgradation )

  1. Maintain Same Versions ( Control plane - Nodes - Autoscalers - Kubelet )

Control plane and Nodes should be on same versions.

Example:

Control plane ( 1.30 ) Nodes (1.29) โ€”> To upgrade cluster to 1.31 from 1.30 make sure nodes are with 1.30.

If you are using Cluster Auto Scaler ..it also should align with same version before upgrading. Also kubelet should be aligned with same version.

  1. Five IP addresses available

Make sure you have atlease 5 ipaddress available in a subnet you provide in cluster.

Actual Process of Upgrading an EKS Cluster

We will take EKS as an example to upgrade.

  1. EKS is a managed Kubernetes service provided by AWS. When we say it is a managed service, it doesnt manage cluster upgrades but manages the following:

โœ๐Ÿป Availability of Control Plane

โœ๐Ÿป Disaster Recovery

โœ๐Ÿป Security

โœ๐Ÿป Scaling API server

  1. Upgrade Node Groups / Nodes / Fargate

Has different approaches. ( You will use rolling / force update strategy โ€”> rolling update ( Zero downtime strategy) )

  1. Upgrade Add-Ons

  2. Understand your k8s cluster well

  3. Test the Upgrade

ย