A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://cloud.google.com/compute/docs/instance-groups/updating-selected-instances-in-a-mig below:

Selectively apply VM configuration updates in a MIG | Compute Engine Documentation

Selectively apply VM configuration updates in a MIG

Stay organized with collections Save and categorize content based on your preferences.

This document describes how to selectively apply configuration updates to the virtual machine (VM) instances in a managed instance group (MIG).

Compute Engine maintains the VMs in a MIG based on the configuration components that you use: instance template, optional all-instances configuration, and optional stateful configuration.

Whenever you update a MIG's VM configuration by changing those components, Compute Engine automatically applies your updated configuration to new VMs that are added to the group.

To apply an updated configuration to existing VMs, you can set up a selective update–also known as a "opportunistic" update type. This type of update offers the following advantages:

Alternatively, if you want to automate the rollout of a new configuration to all or to a random subset of the VMs in a MIG, see Automatically apply VM configuration updates in a MIG. To help you decide, see Methods to apply a new configuration to existing VMs.

Before you begin Apply updated configuration to selected VMs

Ensure your group's update policy type is set to "opportunistic" to prevent the MIG from automatically applying new a VM configuration to existing VMs. For more information, see Check your group's update policy type.

Then use the gcloud CLI or REST to update your MIG's configuration and to apply the latest configuration to specific VMs in the group or to all VMs in the group.

Permissions required for this task

To perform this task, you must have the following permissions:

gcloud

To set up a new instance template for your group, you can use the set-instance-template command.

gcloud compute instance-groups managed set-instance-template INSTANCE_GROUP_NAME \
    --template=INSTANCE_TEMPLATE

Apply configuration to specific VMs

To apply the updated configuration to specific VMs, use the update-instances command with the --instances flag.

gcloud compute instance-groups managed update-instances INSTANCE_GROUP_NAME \
    --instances INSTANCE_NAMES \
    --most-disruptive-allowed-action DISRUPTION_LEVEL \
    --minimal-action DISRUPTION_LEVEL

Apply configuration to all VMs

To apply the updated configuration to all VMs, use the update-instances command with the --all-instances flag.

gcloud compute instance-groups managed update-instances INSTANCE_GROUP_NAME \
    --all-instances \
    --most-disruptive-allowed-action DISRUPTION_LEVEL \
    --minimal-action DISRUPTION_LEVEL

Replace the following:

REST

To set up a new instance template for your group, call the patch method on a zonal or regional MIG and update the versions.instanceTemplate field. To avoid automatically rolling out the new template to all VMs in the group, set the updatePolicy.type field to OPPORTUNISTIC.

PATCH https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceGroupManagers/INSTANCE_GROUP_NAME

{
  "updatePolicy": {
    "type": "OPPORTUNISTIC"
  },
  "versions": [{
    "instanceTemplate": "global/instanceTemplates/NEW_TEMPLATE",
  }]
}

Apply configuration to specific VMs

To apply the updated configuration to specific VMs, call the applyUpdatesToInstances method for your zonal or regional MIG and specify a list of VMs in the request.

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceGroupManagers/INSTANCE_GROUP_NAME/applyUpdatesToInstances
{
  "instances": [
    "zones/ZONE/instances/INSTANCE_NAME_1",
    "zones/ZONE/instances/INSTANCE_NAME_2"
  ],
  "minimalAction": DISRUPTION_LEVEL,
  "mostDisruptiveAllowedAction": DISRUPTION_LEVEL
}

Apply configuration to all VMs

To apply the updated configuration to all existing VMs, set the allInstances field to true:

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceGroupManagers/INSTANCE_GROUP_NAME/applyUpdatesToInstances
{
  "allInstances": true,
  "minimalAction": DISRUPTION_LEVEL,
  "mostDisruptiveAllowedAction": DISRUPTION_LEVEL
}

Replace the following:

Similar to other managed instance group methods, applyUpdatesToInstances is intent-based, which means it returns an operation response. The operation can take some time to complete.

After you make a request, you can check the status to verify that the update is complete.

Control the disruption level during selective updates

Depending on the nature of an update, it might disrupt an instance's state. For example, changing an instance's boot disk requires replacing the instance. You can control the level of disruption during a selective update by setting the following options:

When updating selected VMs, both of these options accept the following values:

Value Description Which instance properties can be updated? NONE Do not disrupt the instance at all. None REFRESH Do not stop the instance. Additional disks, instance metadata, labels, tags RESTART Stop the instance and start it again. Additional disks, instance metadata, labels, tags, machine type REPLACE Delete the instance and create it again. All instance properties stored in the instance template or per-instance configuration

The most disruptive allowed action can't be less disruptive than the minimal action.

When you selectively update VMs, the following defaults apply:

What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-07 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["This document explains how to selectively update the configuration of virtual machines (VMs) within a managed instance group (MIG), allowing control over which VMs are updated and when."],["Selective updates, also known as \"opportunistic\" updates, enable users to choose specific VMs for updates, manage the update timing, and use gcloud CLI or REST for immediate updates."],["The gcloud CLI or REST API can be used to update either specific VMs or all VMs within a MIG to a new configuration."],["Users can manage the level of disruption during selective updates by specifying a minimal action (e.g., `NONE`, `REFRESH`, `RESTART`) and a most disruptive allowed action (e.g., `REPLACE`), with defaults being `NONE` and `REPLACE` respectively."],["Before doing any updates, you must set your instance group update policy to opportunistic to prevent automatic updates, then set the updated information accordingly, as well as the required permissions to run these updates."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4