GOOGLE-PROFESSIONAL-CLOUD-DEVELOPER practice question 1 of 35

You have an application controlled by a managed instance group. When you deploy a new version of the application, costs should be minimized and the number of instances should not increase. You want to ensure that, when each new instance is created, the deployment only continues if the new instance is healthy. What should you do?

Full set: 265 questions
Answer options
A: Perform a rolling-action with maxSurge set to 1, maxUnavailable set to 0.
B: Perform a rolling-action with maxSurge set to 0, maxUnavailable set to 1 Correct answer
C: Perform a rolling-action with maxHealthy set to 1, maxUnhealthy set to 0.
D: Perform a rolling-action with maxHealthy set to 0, maxUnhealthy set to 1.
Correct Answer:
B. Perform a rolling-action with maxSurge set to 0, maxUnavailable set to 1
Explanation

The goal is to update a managed instance group (MIG) without increasing the total number of instances while minimizing costs. The maxSurge and maxUnavailable parameters control the rolling update process. Setting maxSurge=0 ensures that no instances are created above the MIG's target size, directly satisfying the requirement that "the number of instances should not increase." Setting maxUnavailable=1 allows the MIG to take one old instance offline to make capacity for a new one. This "rolling replace" strategy meets the constraints by sequentially replacing old instances with new ones. The MIG inherently waits for a new instance to pass its health check before proceeding with the update, fulfilling the final requirement.

Why Incorrect

A. maxSurge=1 violates the requirement that the number of instances should not increase, as it temporarily creates one instance above the target size.
C. maxHealthy and maxUnhealthy are not valid parameters for configuring a rolling update on a managed instance group. The correct parameters are maxSurge and maxUnavailable.
D. Similar to option C, maxHealthy and maxUnhealthy are not valid parameters for this operation. The update behavior is controlled by maxSurge and maxUnavailable.

References

1. Google Cloud Documentation, "Applying new configurations to VMs in a MIG": Under the section "Rolling update policy," the documentation states: "If you want to maintain the same number of instances throughout an update, set maxSurge to 0 and maxUnavailable to a fixed number greater than 0." This directly supports option B as the correct strategy for an in-place replacement without increasing the instance count.

2. Google Cloud Documentation, "gcloud compute instance-groups managed rolling-action start-update": The command reference defines the flags:

--max-surge: "The maximum number of instances that can be created over the group's target size." Setting this to 0 is required to not increase the instance count.

--max-unavailable: "The maximum number of instances that can be unavailable during the update." Setting this to 1 allows one instance to be replaced at a time.

3. Google Cloud Documentation, "How autohealing works": In the context of updates, this page clarifies the role of health checks: "During a proactive update, the MIG marks an instance for deletion and waits for the new instance to start up and become healthy before it proceeds to delete the original instance." This confirms the health check behavior described in the question is a standard part of the process.

Scroll to Top