How to Upgrade Your GKE Cluster to the Latest Version

Ensure your GKE clusters are secure and efficient by upgrading to the latest version. Follow our guide to manually upgrade your GKE clusters.

Patrick Londa
Author
Dec 14, 2022
 • 
6
 min read
Share this post

Upgrading GKE clusters is a necessary maintenance procedure to ensure your Google Kubernetes Engine (GKE) performs at maximized efficiency and according to your custom operational setups.

Upgrading your GKE clusters to newer versions enhances your state of risk preparedness, protects you against unpredictable contingencies, maximizes your operational efficiency, and optimizes your operating costs over the long haul.

In this guide, we’ll walk through some best practices and show the steps for upgrading your GKE cluster from its current version to the latest.

gcp logo
Blink Automation: Upgrade Your GKE Cluster
Blink + GCP
Get Started

How to Manually Upgrade Your GKE Cluster

Google allows users to initiate a manual upgrade once a new Kubernetes version becomes available. This adds another layer of control to manage your cluster upgrades according to your evolving operational and business needs.

Upgrading your clusters can be done manually using the Google Cloud console or Google Cloud CLI.

Upgrading the GKE Cluster Control Plane

First, you’ll want to upgrade your control plane. Because your control plane is required to make changes to your cluster configuration, you might not be able to make these configuration changes until the upgrade is complete. If you have a regional cluster, you’ll be able to avoid downtime since you will have replicas of the control plane in other zones. 

If you have a zonal or multi-zonal cluster, you should try to time your upgrade for when there is relatively little workload volatility.

Using the Google Cloud Console:

1. Go to Google Kubernetes Engine in the Google Cloud console.

2. On Google Kubernetes Engine, choose which cluster you want to upgrade.

3. Under Cluster basics, click Upgrade Available next to Version.

4. Select your desired version, and click Save Changes.

Using the Google Cloud CLI:

1. Check available versions by running this command:

gcloud container get-server-config

2. Upgrade to default cluster version by running this command:

gcloud container clusters upgrade <CLUSTER_NAME> --master

You can upgrade to a specific version by running that same command with the --cluster-version flag:

gcloud container clusters upgrade <CLUSTER_NAME> --master     
    --cluster-version <VERSION>

While you can skip minor versions when upgrading the control plane with the CLI, it isn’t recommended in order to avoid incompatibility between your nodes and your control plane.

Upgrading GKE Cluster Node Pools

Cluster nodes are set to auto-upgrade by default, but you can also manually upgrade them. Nodes within the pool will be upgraded one by one randomly until they are all replaced.

If you have workloads running on a node pool, the upgrade process may disrupt them. If you want to avoid this, you can create a new node pool with the newer version, migrate the workload, and then eliminate the out-of-date node pool. If you have PodDisruptionBudgets (PDBs) or Pod termination grace period settings in place, they will be respected for 1 hour at max, and then the upgrade will move forward.

If you have data on a Pod that you want to ensure isn’t deleted during an upgrade, you need to store that data in a Pod using persistent volumes. These types of volumes use persistent disks, which are unmounted instead of eliminated during upgrades. You can see how to add persistent disks here.

Using the Google Cloud console

1. In the Google Cloud console, go to the Google Kubernetes Engine page. 

2. Click on the name of the specific cluster to view the Cluster details page.

3. In the Node Pools section of the Nodes tab, select the name of the Node pool you want to upgrade.

4. Click Edit, then Change under Node version.

5. Choose the version you want to upgrade to from the Node version drop down, then click Change. Your node pools must be within 2 minor versions of your control plane’s current version to be compatible.

Using the Google Cloud CLI

You can run this command to manually upgrade node pools:

gcloud container clusters upgrade <CLUSTER_NAME> 
  --node-pool=<NODE_POOL_NAME>
  --cluster-version <VERSION>

You can use the  --cluster-version <VERSION> flag, to select any version within 2 minor versions of your control plane’s version to maintain compatibility. If you don’t specify a version, it will default to the current master version.

Monitoring Your Node Pool Upgrade

You can check the status of your upgrade by running the gcloud container operations list command. Once you see the Operation ID with an Upgrade_Cluster type, you can use the gcloud container operations describe command to get more information:

Here’s an example:

gcloud container operations describe operation-1507325726639-981f0ed6
endTime: '20xx-xx-xxT21:40:05.324124385Z'
name: operation-1507325726639-981f0ed6
operationType: UPGRADE_CLUSTER
selfLink: https://container.googleapis.com/v1/projects/.../kubernetes-engine/docs/zones/us-central1-a/operations/operation-1507325726639-981f0ed6
startTime: '20xx-xx-xxT21:35:26.639453776Z'
status: DONE
targetLink: https://container.googleapis.com/v1/projects/.../kubernetes-engine/docs/zones/us-central1-a/clusters/...
zone: us-central1-a

If you want to cancel your upgrade, you can use the upgrade Operation ID value in the gcloud container operations cancel command.

You can rollback an upgrade if it was canceled or failed by using the gcloud container node-pools rollback command, but you cannot downgrade after a successful upgrade.

Running GKE Cluster Upgrades Simply with Blink

Every time you want to manually upgrade your clusters to the latest version, you’ll need to minimize disruptions, adjust workloads, and notify team members. You might have a standard practice for managing upgrades, but it is time-intensive and requires context-switching to send out communications.

With Blink, you can automate notifications, put your upgrade steps on rails with conditional logic, and full visibility into the upgrade progress.

Get started with Blink today and streamline your cluster upgrades today.