0

I want to create a new instance template based on existing one, with just a new container (docker).

The docs say to use,

gcloud compute instance-templates create INSTANCE_TEMPLATE_NAME
--source-instance=SOURCE_INSTANCE
--source-instance-zone=SOURCE_INSTANCE_ZONE

But my template is a global resource not in a zone, and cannot be found.

The "create similar" in the instance template console gives an equivalent gcloud command but that fails with an error (13 Sept 2022).

(gcloud.compute.instance-templates.create-with-container) argument --create-disk: valid keys are [architecture, auto-delete, description, device-name, disk-resource-policy, image, image-family, image-project, mode, name, provisioned-iops, size, type]; received: boot

According to gcloud it is up to date.

How can I automate instance template generation with a new docker image?

Console creation/"create similar" works, but not cli.

Note: Creation with equivalent cli command given by the console fails with the same error as above.

GAllan
  • 409
  • 4
  • 11

1 Answers1

0

I eventually used a "version" of the equivalent cli. Removing the --create-disk option and replacing that with some boot disk options. The cmd also needed the addition of ',address=""' to the network interface option to get an external ip address.

Note your --tags may differ based on your firewall tags. The --boot-disk-device-name can be any name, as far as I can see!

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
GAllan
  • 409
  • 4
  • 11