0

Is it possible in Google cloud engine to clone an existing instance template AND override the container image in the clone ?

the concrete situation is as follows:

We have a GCP project that consists of several gcp components including a managed instances group (MIG) which references an intance template.

In order to deploy (by a separeted CI/CD pipeline) new container image versions in the MIG we woud like (if possible) to clone the existing instance template, just overwrite the container-image in the clone and update the MIG with the clone.

Hence the questions:
is it possible to create an instance template by cloning an existing one and just overriding the container-image in the clone (without specifying all the other template settings)?
What is the best way to deploy a new container-image version in an existing MIG without creating a new instance template from scratch?

Thanks in advance for any answer!

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Aug 23 '23 at 17:27

1 Answers1

0

As per GAllan, they use an equivalent version of the 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

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.

-tags may differ based on your firewall tags. The --boot-disk-device-name can be any name.

Dion V
  • 356
  • 2
  • 7
  • Thats just what I m doing right now as temporary solution. I m not fine with this solution, as the template is defined twice: in the terraform scripts (initializing the whole project infrastructure) as well as in the deployment pipeline :-( – Najib Bakahoui Aug 24 '23 at 07:40