在 Google CE 中是否可以从另一个现有模板创建新的实例模板并覆盖原始模板中的容器映像?
具体情况如下:
a) 我喜欢使用 google 托管实例组 (MIG) 来部署我的工件。
b) MIG 以及实例模板(带有占位符容器映像)由管道初始化一次,该管道创建(通过 terraform)我的 GCP 项目的整个基础设施。实例模板指定有关 VM 的网络、自动调用、磁盘、机器类型等的所有内容,这些内容稍后将在 MIG 中运行。
现在是关于如何在 MIG 中最好地部署我的工件的新版本?
我理解:由于实例模板无法更改,因此要创建新模板才能部署......
我现在的问题是:有没有一种方法可以通过复制初始模板来创建新的实例模板,并且仅覆盖内部的“容器映像”,而无需再次指定所有特定于基础设施的设置(网络、磁盘等...... )
提前感谢任何答复!
根据 GAllan,他们使用 cli 的等效版本:
gcloud compute instance-templates create-with-container $myTemplateName \
--container-image=$myrepo/$myimage \
--boot-disk-size 10GB --boot-disk-device-name exchange-template \
--boot-disk-type=pd-balanced --project=$myproject \
--machine-type=e2-medium \
--network-interface=network=default,network-tier=PREMIUM,address="" \
--maintenance-policy=MIGRATE \
--service-account=$myServiceAccount --scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/trace.append \
--tags=http-server,https-server,allowport8080 \
--container-restart-policy=always \
--no-shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring
删除 --create-disk 选项并将其替换为一些启动磁盘选项。
cmd 还需要在网络接口选项中添加 ',address=""' 来获取外部 IP 地址。
-标签可能因您的防火墙标签而异。 --boot-disk-device-name 可以是任何名称。