图像家族和重大变化!!

图像别名

在Compute Engine的镜像中原本有一个名为Alias的属性,当指定了Alias时,将使用其中最新的镜像。

假设有多个具有debian-8别名的镜像,将选择其中名称最大的镜像。

gcloud compute instances create --image debian-8
# debian-8-jessie-v20160606 が使われる

图像列表

Image Name                 Alias
debian-8-jessie-v20160511  debian-8
debian-8-jessie-v20160606  debian-8
debian-8-jessie-v20160511                          debian-cloud     debian-8            DEPRECATED  READY
debian-8-jessie-v20160606                          debian-cloud     debian-8                        READY

如果仅指定 Debian-8,它将为您选择最新的Debian-8,这是一个方便的功能。
然而,别名无法在自定义镜像中设置,它是专为预设镜像而存在的功能。

因此,如果您正在指定自定义图像并创建图像模板,每次升级版本都需要重新创建图像模板。

图像家族

为了改变这种情况,image-family应运而生。image-family可以像别名一样设置为Image,并且可以在创建实例时进行指定。此外,现在还可以将image-family设置为自定义镜像。

gcloud compute images create HOGE --family FAMILY
NAME               FAMILY
image-v20160517a   sample                         
image-v20160517b   sample

如果使用image-family,请明确使用–image-family选项。

gcloud compute instances create HOGE --image-family FAMILY

如果在FAMILY中指定了sample,则会使用sample中名称最大的 image-v20160517b。
这样一来,每次更新Custom Image时,就不需要更改指定image的NAME了。

破坏性变更

由于image-family的发布,无法再使用image aliases。因此,如果要指定–image,请务必提供完整的image名称。

注意,在gcloud sdk 114.0.0版本后生效,更新时请小心。

gcloud compute instances create hoge --image "/debian-cloud/debian-8-jessie-v20160606"

114.0.0(2016/06/15)

Breaking Changes
      ▪ (Google Compute Engine) Deprecated the use of image aliases. Please
        use image families instead. See
        https://cloud.google.com/compute/docs/images for more details.
bannerAds