Question

Difficulty: MediumManaging Compute Engine Resources

An Associate Cloud Engineer needs to deploy a new version of a stateless web application running on an existing regional Managed Instance Group (MIG) with zero downtime using the gcloud CLI. Order the steps required to execute this deployment correctly from first to last.

  1. 1Create a new Instance Template incorporating the updated application disk image and startup configuration using 'gcloud compute instance-templates create'.
  2. 2Update the Managed Instance Group configuration to reference the newly created Instance Template using 'gcloud compute instance-groups managed set-instance-template'.
  3. 3Initiate a rolling replacement of existing instances across the group using 'gcloud compute instance-groups managed rolling-action start-update'.
  4. 4Monitor the health status and deployment progress of the replacement instances using 'gcloud compute instance-groups managed list-instances'.

Answer

The correct operational sequence is: first, create the updated Instance Template; second, assign the template to the Managed Instance Group; third, launch the rolling update action; and fourth, monitor instance health and deployment completion.
The Google Cloud recommended workflow for updating a Managed Instance Group requires creating an immutable Instance Template first, attaching that template to the target MIG, triggering the rolling update action to replace existing VMs, and finally verifying instance health.

Step-by-Step Solution

1
Run 'gcloud compute instance-templates create' with the new image tag/configuration.
A new instance template resource is created in the project.
Managed Instance Groups cannot update running VMs without a target instance template defining the desired state.
2
Run 'gcloud compute instance-groups managed set-instance-template' pointing to the new template.
The MIG metadata is updated to point to the new template.
The group manager needs to know which template to use when launching new VM instances.
3
Run 'gcloud compute instance-groups managed rolling-action start-update' with desired surge and availability parameters.
The MIG control plane begins replacing old instances with new instances in batches.
This initiates the actual rolling replacement process while preserving minimum operational capacity.
4
Run 'gcloud compute instance-groups managed list-instances' to observe instance status flags.
Confirms that all instances reach the RUNNING state and pass health checks.
Continuous verification ensures the update completed successfully without application degradation.

Key Concept

Managed Instance Group Rolling Updates via gcloud CLI
Rate this question