Reader small image

You're reading from  The Kubernetes Workshop

Product typeBook
Published inSep 2020
PublisherPackt
ISBN-139781838820756
Edition1st Edition
Right arrow
Authors (6):
Zachary Arnold
Zachary Arnold
author image
Zachary Arnold

Zachary Arnold works as a software engineer at Ygrene Energy Fund. Zach has an experience of over 10 years in modern web development. He is an active contributor to the Open Source Kubernetes project in both SIG-Release and SIG-Docs currently focusing on security. He has been running clusters in production since Kubernetes 1.7 and has spoken at the previous 4 KubeCons. His passion areas in the project center on building highly stable Kubernetes cluster components and running workloads securely inside of Kubernetes.
Read more about Zachary Arnold

Sahil Dua
Sahil Dua
author image
Sahil Dua

Sahil Dua is a software engineer. He started using Kubernetes to run machine learning workloads. Currently, he is running various types of applications on Kubernetes. He shared his learnings as a keynote session at KubeCon Europe 2018. He is a passionate open source contributor and has contributed to some famous projects such as Git, pandas, hound, go-GitHub, and so on. He has been an open source community leader for over 2 years at DuckDuckGo.
Read more about Sahil Dua

Wei Huang
Wei Huang
author image
Wei Huang

Wei Huang: Wei works as a senior software engineer in IBM. He has over 10 years' experiences around database, data warehouse tooling, cloud, container, monitoring and devops. He started to use Kubernetes since 1.3, including extending Kubernetes LoadBalancer using CRD, networking, scheduling and monitoring. Now he is a core maintainer of Kubernetes SIG-Scheduling.
Read more about Wei Huang

Faisal Masood
Faisal Masood
author image
Faisal Masood

Faisal Masood is a cloud transformation architect at AWS. Faisal's focus is to assist customers in refining and executing strategic business goals. Faisal main interests are evolutionary architectures, software development, ML lifecycle, CD and IaC. Faisal has over two decades of experience in software architecture and development.
Read more about Faisal Masood

Mélony Qin
Mélony Qin
author image
Mélony Qin

Mélony Y. QIN, also known as CloudMelon, is the founder of CloudMelon Vis, a tech media and educational platform for technopreneurs in the cloud-native and serverless space, and a former product manager at Microsoft. With a passion for cloud-native technologies, OSS, DevOps, Kubernetes, serverless, data, and AI, Mélony has authored multiple books, including the Certified Kubernetes Administrator (CKA) Exam Guide, the Kubernetes Workshop, and Microsoft Azure Infrastructure, all published by Packt Publishing. Mélony is a member of the Association for Computing Machinery (ACM) and the Project Management Institute (PMI), leveraging her extensive experience with diverse cloud technologies to drive innovation in the cloud-native, serverless, and generative AI space. She runs the CloudMelonVis YouTube channel and Cloud-Native Innovators newsletter, read by professionals from top tech companies such as Microsoft, Google, Amazon, Dell, and Carrefour.
Read more about Mélony Qin

Mohammed Abu Taleb
Mohammed Abu Taleb
author image
Mohammed Abu Taleb

Mohammed Abu-Taleb works as a Technical Advisor at Microsoft. Working at Microsoft CSS team for troubleshooting complex issues and cases for premier customers that are using Azure Kubernetes Services (AKS). Prior that, Mohammed was a SME (subject matter expert) for the azure managed monitoring service (Azure Monitor) focusing on designing, deploying, and troubleshooting monitoring strategies for containers.
Read more about Mohammed Abu Taleb

View More author details
Right arrow

18. Upgrading Your Cluster without Downtime

Overview

In this chapter, we will discuss how to upgrade your cluster without downtime. We will first understand the need to keep your Kubernetes cluster up to date. Then, we will understand basic application deployment strategies that can help zero-downtime upgrades of the Kubernetes cluster. We will then put these strategies into action by performing an upgrade on a Kubernetes cluster with no downtime for your application.

Introduction

We learned how to set up a multi-node Kubernetes platform on AWS using kops in Chapter 11, Build Your Own HA Cluster. In this chapter, you will learn about upgrading the Kubernetes platform to a new version. We will walk you through hands-on examples of the steps that are required to upgrade the Kubernetes platform. These exercises will also equip you with the skills required to maintain a Kubernetes cluster.

Different organizations set up and maintain their Kubernetes clusters in different ways. You saw in Chapter 12, Your Application and HA, that there are numerous ways to set up a cluster. We will present a simple technique to upgrade your cluster and, depending on the cluster you are dealing with, the exact techniques and steps that you will need to take for upgrading may be different, although the basic principles and precautions that we will mention here will be applicable regardless of how you go about upgrading your cluster.

The Need to Upgrade Your Kubernetes Cluster

Building up your business application and putting it out in the world is only half the game. Making your application usable by customers in a secure, scalable, and consistent way is the other half and the one that you have to keep working on. To be able to execute this other half well, you need a rock-solid platform.

In today's highly competitive environment, delivery of the latest features to customers in a timely manner is important to give your business an edge. This platform has to not only be dependable but also provide new and updated features to keep up with the demands of running modern applications. Kubernetes is a fast-moving platform and is well suited for such a dynamic environment. The pace of development and advancement of Kubernetes is evidenced by the number of commits in the official Kubernetes GitHub repository. Let's take a look at the following screenshot:

Figure 18.1: Daily commits to...

Kubernetes Components – Refresher

By now, you are already aware of the basic components of the Kubernetes platform. Just as a refresher, let's revisit the major components:

  • The API server is responsible for exposing RESTful Kubernetes APIs and is stateless. All users on your cluster, Kubernetes master components, kubectl clients, worker nodes, and maybe even your application all need to interact with the API server.
  • A key-value store (the etcd server) stores the objects and provides a persistent backend to the API server.
  • The scheduler and controller manager act to attain the state of the cluster and objects stored in etcd.
  • kubelet is a program that runs on every worker node and behaves like an agent to perform the work as directed by Kubernetes master components.

When we update the platform, as you will see in the later sections, we are going to utilize these components and upgrade them as separate modules.

A Word of Caution

Kubernetes...

The Upgrade Process

In this section, you will see the steps required to upgrade the Kubernetes platform. Note that upgrading the underlying OS is not covered here. To meet the requirement of zero-downtime upgrades, you must have an HA Kubernetes cluster with a minimum of three masters and etcd servers, which enables frictionless upgrades. The process will take one node out of the three and upgrade it. The upgraded component then will rejoin the cluster, and then we take the second node and apply the upgrade process to it. Since, at any given time, at least two of the servers are kept available, the cluster will remain available during the upgrade.

Some Considerations for kops

We have guided you through the creation of an HA Kubernetes cluster in Chapter 11, Build Your Own HA Cluster. Hence, in this chapter, we will walk you through upgrading the same cluster.

As mentioned in that chapter, there are various ways of deploying and managing a Kubernetes cluster. We have opted...

Upgrading Kubernetes Master Components

When you are running Kubernetes in any capacity that is important for your organization, you will be running the platform in an HA configuration. To achieve that, the typical configuration is at least three replicas of master components, running on three different nodes. This allows you to upgrade single nodes from one minor version to the next, one by one, while still maintaining API compatibility when an upgraded node rejoins the cluster because Kubernetes provides compatibility across one minor version. This means the master components can be on different versions when you are upgrading each node at a time. The following table provides a logical flow of the versions. Let's assume you are upgrading from version 1.14 to 1.15:

Figure 18.14: Upgrade plan for three master nodes

In the following exercise, we will proceed with upgrading the Kubernetes master components.

Exercise 18.03: Upgrading Kubernetes Master...

Upgrading Kubernetes Worker Nodes

Although Kubernetes supports compatibility between master (API server) and worker nodes (kubelet) within one minor version, it is highly recommended that you upgrade the master and worker nodes in one go. Using kops, upgrading worker nodes is similar to upgrading master nodes. Due to the backward compatibility within one minor version, the worker nodes may still work if they are not version-matched by the master nodes, but it is strongly discouraged to run different versions of Kubernetes on worker and master nodes since this may create problems for the cluster.

However, the following considerations are of extreme importance if you want to keep your application online during the upgrade:

  • Make sure that your applications are configured to be highly available. This means that you should have at least two pods, each on different nodes, for each of your applications. If this is not the case, your applications may experience downtime once you...

Summary

In this chapter, you have learned that keeping your Kubernetes platform up to date is very important when it comes to providing a secure and reliable foundation for running your applications. In this fast-moving digital world, many businesses rely on critical applications and keeping them available, even though upgrading the underlying platform is important.

You have seen that a no-downtime upgrade of the platform is possible if you have set up the cluster in a high availability configuration to start with. However, the platform does not guarantee the availability of your applications unless you have designed and deployed your application in a fault-tolerant manner. One factor is to make sure that you have multiple instances of your application running and that the application is designed to handle the termination of these instances gracefully.

With that taken into account, we have seen the important considerations for upgrading your cluster in a way that the platform...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
The Kubernetes Workshop
Published in: Sep 2020Publisher: PacktISBN-13: 9781838820756
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (6)

author image
Zachary Arnold

Zachary Arnold works as a software engineer at Ygrene Energy Fund. Zach has an experience of over 10 years in modern web development. He is an active contributor to the Open Source Kubernetes project in both SIG-Release and SIG-Docs currently focusing on security. He has been running clusters in production since Kubernetes 1.7 and has spoken at the previous 4 KubeCons. His passion areas in the project center on building highly stable Kubernetes cluster components and running workloads securely inside of Kubernetes.
Read more about Zachary Arnold

author image
Sahil Dua

Sahil Dua is a software engineer. He started using Kubernetes to run machine learning workloads. Currently, he is running various types of applications on Kubernetes. He shared his learnings as a keynote session at KubeCon Europe 2018. He is a passionate open source contributor and has contributed to some famous projects such as Git, pandas, hound, go-GitHub, and so on. He has been an open source community leader for over 2 years at DuckDuckGo.
Read more about Sahil Dua

author image
Wei Huang

Wei Huang: Wei works as a senior software engineer in IBM. He has over 10 years' experiences around database, data warehouse tooling, cloud, container, monitoring and devops. He started to use Kubernetes since 1.3, including extending Kubernetes LoadBalancer using CRD, networking, scheduling and monitoring. Now he is a core maintainer of Kubernetes SIG-Scheduling.
Read more about Wei Huang

author image
Faisal Masood

Faisal Masood is a cloud transformation architect at AWS. Faisal's focus is to assist customers in refining and executing strategic business goals. Faisal main interests are evolutionary architectures, software development, ML lifecycle, CD and IaC. Faisal has over two decades of experience in software architecture and development.
Read more about Faisal Masood

author image
Mélony Qin

Mélony Y. QIN, also known as CloudMelon, is the founder of CloudMelon Vis, a tech media and educational platform for technopreneurs in the cloud-native and serverless space, and a former product manager at Microsoft. With a passion for cloud-native technologies, OSS, DevOps, Kubernetes, serverless, data, and AI, Mélony has authored multiple books, including the Certified Kubernetes Administrator (CKA) Exam Guide, the Kubernetes Workshop, and Microsoft Azure Infrastructure, all published by Packt Publishing. Mélony is a member of the Association for Computing Machinery (ACM) and the Project Management Institute (PMI), leveraging her extensive experience with diverse cloud technologies to drive innovation in the cloud-native, serverless, and generative AI space. She runs the CloudMelonVis YouTube channel and Cloud-Native Innovators newsletter, read by professionals from top tech companies such as Microsoft, Google, Amazon, Dell, and Carrefour.
Read more about Mélony Qin

author image
Mohammed Abu Taleb

Mohammed Abu-Taleb works as a Technical Advisor at Microsoft. Working at Microsoft CSS team for troubleshooting complex issues and cases for premier customers that are using Azure Kubernetes Services (AKS). Prior that, Mohammed was a SME (subject matter expert) for the azure managed monitoring service (Azure Monitor) focusing on designing, deploying, and troubleshooting monitoring strategies for containers.
Read more about Mohammed Abu Taleb