Bob Risky
Bob Risky

Reputation: 935

How to programmatically get list of supported Kubernetes versions for GKE?

The supported versions are listed here:

https://cloud.google.com/container-engine/supported-versions

but I'm wondering if there is a way to programatically get this list (besides scraping that page, I guess) via gcloud or some similar tool?

I find that hard-coding a single version breaks often because Google keeps updating the supported versions. At the same time, I /would/ like to specify at least the large version (e.g., 1.7.x) because it appears that 1.8.x introduces some breaking changes, for example.

Upvotes: 6

Views: 4282

Answers (3)

lalyos
lalyos

Reputation: 793

Choose channel from

  • RAPID
  • REGULAR
  • STABLE
gcloud container get-server-config \
      --region=YOUR-REGION \
      --flatten=channels \
      --filter="channels.channel=REGULAR" \
      --format="value(channels.defaultVersion)"

Upvotes: 0

Fabio Yeon
Fabio Yeon

Reputation: 251

The gcloud "get-server-config" will get you the data you want. Specifying the "--format" option can also return it in a way that's easy to parse:

gcloud container get-server-config --zone=us-central1-f --format=json

If you wish to control when updates happen, the maintenance window option may also help you control when you want them to occur. https://cloud.google.com/container-engine/docs/maintenance-window

Upvotes: 15

David
David

Reputation: 9721

The projects.zones.getServerconfig method returns versions that you can use. This is not quite the same as the supported verisons page you link, which includes versions which may exist in legacy clusters but are no longer available. However for purposes of upgrading or creating new clusters, this list is the one you want.

Upvotes: 2

Related Questions