Creating an Autopilot cluster at a specific version

2 min read

Sometimes you may wish to create a GKE Autopilot cluster with a specific version. For example, the big news this week is that mutating webhooks are finally supported in Autopilot (from version 1.21.3-gke.900). While you will likely need to wait a bit for this to hit the Regular release channel for production stability, if you have a workload blocked then you might want to try it out now and get it ready.

Through the UI, you can choose the release channel but each release channel actually has a few different versions. Rapid is the obvious release channel to use for testing new features, but you can be even more “rapid” than Rapid by specifying the version. Today, this has to be done on the command line.

Here’s how:

Firstly, you can view the list of available versions for each channel like so:

$ gcloud container get-server-config --region us-west1 \
    --format="yaml(channels)"

Fetching server config for us-west1
channels:
- channel: RAPID
  defaultVersion: 1.21.4-gke.2300
  validVersions:
  - 1.22.2-gke.1300
  - 1.21.3-gke.900
  - 1.21.5-gke.1300
  - 1.21.4-gke.2300
- channel: REGULAR
  defaultVersion: 1.20.10-gke.301
  validVersions:
  - 1.21.3-gke.2001
  - 1.20.10-gke.1600
  - 1.20.10-gke.301
  - 1.20.9-gke.1001
- channel: STABLE
  defaultVersion: 1.19.13-gke.1900
  validVersions:
  - 1.20.10-gke.1600
  - 1.20.10-gke.301
  - 1.19.14-gke.1900
  - 1.19.13-gke.1900

As we can see, the version I’m looking for 1.21.3-gke.900 is available. This version release won’t be around forever, so when you run this command, pick any valid version you want to try.

Now, specify both the channel and the version you desire:

CLUSTER_NAME=test-cluster
gcloud container clusters create-auto $CLUSTER_NAME \
    --release-channel "rapid" --region "us-west1" \
    --cluster-version "1.21.3-gke.900"

For existing clusters, you can query their current version and release channel like so:

gcloud container clusters describe $CLUSTER_NAME \
    --region us-west1 \
    --format="yaml(releaseChannel,currentMasterVersion)"

And upgrade them to any version available in that release channel (as discovered with the get-server-config command above), with the following:

gcloud container clusters upgrade $CLUSTER_NAME \
    --region us-west1 \
    --master --cluster-version "1.22.2-gke.1901"