Listing Debian or Ubuntu Image family on GKE using cli

Quick Tip: How to list the currently-recommended, newest versions of Debian, Ubuntu images on Google Compute Engine, using the Google Cloud SDK command line tool gcloud.

Listing Current Images – Debian

gcloud compute images list --project=debian-cloud --no-standard-images

NAME                        PROJECT       FAMILY     DEPRECATED  STATUS
debian-10-buster-v20191014  debian-cloud  debian-10              READY
debian-9-stretch-v20191014  debian-cloud  debian-9               READY

Listing Current Images – Ubuntu

gcloud compute images list --project=ubuntu-os-cloud --no-standard-images

NAME                                  PROJECT          FAMILY                   DEPRECATED  STATUS
ubuntu-1404-trusty-v20190514          ubuntu-os-cloud  ubuntu-1404-lts                      READY
ubuntu-1604-xenial-v20191024          ubuntu-os-cloud  ubuntu-1604-lts                      READY
ubuntu-1804-bionic-v20191021          ubuntu-os-cloud  ubuntu-1804-lts                      READY
ubuntu-1904-disco-v20191020           ubuntu-os-cloud  ubuntu-1904                          READY
ubuntu-1910-eoan-v20191022            ubuntu-os-cloud  ubuntu-1910                          READY
ubuntu-minimal-1604-xenial-v20191024  ubuntu-os-cloud  ubuntu-minimal-1604-lts              READY
ubuntu-minimal-1804-bionic-v20191024  ubuntu-os-cloud  ubuntu-minimal-1804-lts              READY
ubuntu-minimal-1904-disco-v20191019   ubuntu-os-cloud  ubuntu-minimal-1904                  READY
ubuntu-minimal-1910-eoan-v20191022    ubuntu-os-cloud  ubuntu-minimal-1910                  READY

Listing Older and Deprecated Images

As Google Compute Engine releases new images, older images will be deprecated and eventually removed. When this happens, Google Compute Engine sets the deprecation status on an image

# DEBIAN
gcloud compute images list --project=debian-cloud --no-standard-images --show-deprecated

NAME                                               PROJECT       FAMILY              DEPRECATED  STATUS
backports-debian-7-wheezy-v20131127                debian-cloud                      DEPRECATED  READY
backports-debian-7-wheezy-v20140318                debian-cloud                      DEPRECATED  READY
backports-debian-7-wheezy-v20140331                debian-cloud                      DEPRECATED  READY
...

# UBUNTU
gcloud compute images list --project=ubuntu-os-cloud --no-standard-images --show-deprecated

NAME                                   PROJECT          FAMILY                   DEPRECATED  STATUS
ubuntu-1204-precise-v20141028          ubuntu-os-cloud                           DEPRECATED  READY
ubuntu-1204-precise-v20141031          ubuntu-os-cloud                           DEPRECATED  READY
ubuntu-1204-precise-v20141212          ubuntu-os-cloud                           DEPRECATED  READY
...

Using the images

Example: To use the most up to date Debian 10 Buster image, use the “debian-10” image family when creating a new instance and include the --image-project args too

gcloud compute instances create "<instance-name>" \ 
     --image-project debian-cloud --image-family debian-10 \ 
     --zone="<zone>"
     ...