Upgrade GKE Control Plane

This section will walk you through the steps required to upgrade the control plane of a GKE cluster.

What You’ll Need

Check Your Environment

Before you start upgrading the GKE control plane, follow the next steps to ensure that your environment meets the requirements:

  1. Get the Kubernetes version of your cluster control plane by inspecting the Server Version in the following command:

    root@rok-tools:~# kubectl version --short Client Version: v1.18.19 Server Version: v1.19.16-gke.6800
  2. Get the Kubernetes version of your nodes:

    root@rok-tools:~# kubectl get nodes -o json | \ > jq -r '.items[].status.nodeInfo.kubeletVersion' v1.19.16-gke.6800 v1.19.16-gke.6800
  3. Verify that the Kubernetes minor version of your nodes found in step 2 is the same as the control plane’s current minor version found in step 1. Otherwise, first update your node pool to the control plane’s current version and return to follow this guide.

    Note

    For example, if your control plane is running version 1.20 and any of your nodes are running version 1.19, update your nodes to version 1.20 before updating your control plane’s Kubernetes version to 1.21.

  4. Get the Rok version running in your GKE cluster:

    root@rok-tools:~# kubectl get -n rok rokcluster rok -o json | \ > jq -r '.status.version' release-1.5-l0-release-1.5.1
  5. Ensure that the version you found matches the latest Rok version release-1.5-l0-release-1.5.1. Otherwise, first upgrade your Rok cluster to the latest Rok version and return to follow this guide.

Procedure

  1. Specify your GKE cluster:

    root@rok-tools:~# export GKE_CLUSTER=<GKE_CLUSTER>

    Replace <GKE_CLUSTER> with the name of your GKE cluster, for example:

    root@rok-tools:~# export GKE_CLUSTER=arrikto-cluster
  2. Specify the new Kubernetes version. Choose one of the following options, based on the Kubernetes version you want to upgrade to:

    root@rok-tools:~# export CLUSTER_VERSION=1.21
    root@rok-tools:~# export CLUSTER_VERSION=1.20
  3. Upgrade the control plane of your GKE cluster to the new Kubernetes version:

    root@rok-tools:~# gcloud container clusters upgrade ${GKE_CLUSTER?} \ > --master \ > --cluster-version ${CLUSTER_VERSION?} Upcoming breaking change: Starting with v1.22, Kubernetes has removed several v1beta1 APIs for more stable v1 APIs. Read more about this change - https://cloud.google.com/kubernetes-engine/docs/deprecations/apis-1-22. Please ensure that your cluster is not using any deprecated v1beta1 APIs prior to upgrading to GKE 1.22. Master of cluster [arrikto-cluster] will be upgraded from version [1.19.16-gke.6800] to version [1.20]. This operation is long-running and will block other operations on the cluster (including delete) until it has run to completion. Do you want to continue (Y/n)? Y Upgrading arrikto-cluster...done. Updated [https://container.googleapis.com/v1/projects/myproject/zones/us-east1-b/clusters/arrikto-cluster].

    Note

    You can update only one minor version at a time. Therefore, if your current version is 1.19 and you want to update to 1.21, then you must first update your cluster to 1.20 and then update it from 1.20 to 1.21.

Verify

  1. Ensure that the status of your GKE cluster is RUNNING:

    root@rok-tools:~# gcloud container clusters describe ${GKE_CLUSTER?} \ > --format "value(status)" RUNNING
  2. Get the Kubernetes version of your cluster control plane by inspecting the Server Version in the following command and ensure that it matches the new Kubernetes version. Choose one of the following options, based on the upgrade you’ve made:

    root@rok-tools:~# kubectl version --short Client Version: v1.18.19 Server Version: v1.21.5-gke.1805
    root@rok-tools:~# kubectl version --short Client Version: v1.18.19 Server Version: v1.20.15-gke.2500

Summary

You have successfully upgraded the control plane of your GKE cluster.

What’s Next

The next step is to upgrade the node pool of your GKE cluster.