A RetroSearch Logo

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

Search Query:

Showing content from https://cloud.google.com/compute/docs/instance-groups/updating-migs below:

Apply new VM configurations in a MIG | Compute Engine Documentation

This page explains how you can configure the virtual machine (VM) instances in a managed instance group (MIG) and the methods you can use to apply the configuration to existing VMs in the group.

You specify the intended configuration for the VMs in a MIG by using the following VM configuration components:

Whenever you update the intended configuration by using 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, use the methods described on this page:

You can also configure your MIG to apply the latest available configuration to VMs during VM repairs. For more information, see Apply configuration updates during repairs.

If you only need to resize a MIG, see the documentation for how to add or remove VMs in a MIG. If you want to learn about configuring MIG features, see the docs for autoscaling, autohealing, load balancing, and stateful workloads.

Before you begin Configuration components for VMs in a MIG

You configure the VMs in a MIG through the following components:

Component Properties Use case Instance template Machine type, boot disk image, labels, startup script, and other VM properties Required: Use an instance template to define required and optional instance properties for all VMs in the group.

Optional: If you want to canary test a second VM configuration, you can add a second instance template to the group and apply it to a subset of the VMs in the group.

All-instances configuration Labels and metadata Optional: Use an all-instances configuration to quickly override instance template properties for all VMs in the group. Stateful configuration Stateful disks, IP addresses, and metadata Optional: If you need to support a stateful workload, add stateful configuration to VMs in the group.

If you update any configuration for the group through those components, you must apply the updated configuration to existing VMs in the group in order to make the updated configuration effective.

Methods to apply a new configuration to existing VMs

After you update a MIG's VM configuration, you can apply the new configuration to existing VMs in the group by using the following methods:

For more information about setting a MIG's update type, see Set up a proactive or an opportunistic update.

Automatic (proactive)

An automatic update type is also known as a proactive update type. When you set the MIG's update type to proactive, the MIG automatically applies updated configurations to VMs as necessary.

Setting the MIG's update type to proactive offers two primary advantages:

To learn how to set the MIG's update type, see Set up a proactive or an opportunistic update.

For more information about automatic rollouts, see Automatically apply VM configuration updates in a MIG.

Selective (opportunistic)

A selective update type is also known as an opportunistic update type. When you set the MIG's update type to opportunistic, the MIG applies new configurations to existing VMs only when you selectively target specific VMs to be updated.

Setting the MIG's update type to opportunistic offers the following advantages:

In certain scenarios, a selective update type is useful because you don't want to cause instability to the system if it can be avoided. For example, consider the following:

To learn how to set the MIG's update type, see Set up a proactive or an opportunistic update.

For more information about selectively updating VMs, see Selectively apply VM configuration updates in a MIG.

Re-creation of VMs

You can re-create any VM in a MIG. When you do, the MIG applies any updated configuration that has not yet been applied to that VM. For more information, see Re-creating VMs in a MIG.

Set up a proactive or an opportunistic update

To apply new configurations to existing VMs automatically, set the MIG's update type to "proactive". To apply new configurations to existing VMs only when you select a VM to be updated, set the MIG's update type to "opportunistic".

Use the Google Cloud console, the Google Cloud CLI, or REST.

Permissions required for this task

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

Console
  1. In the Google Cloud console, go to the Instance groups page.

    Go to the Instance groups page

  2. Select the MIG that you want to update.

  3. Click Edit.

  4. Click Update policy to expand the section.

  5. Choose either Selective or Automatic update.

  6. Optional: If you choose Automatic, then you can set the additional options or use the default values.

  7. Click Save.

gcloud

Use the rolling-action start-update command and set the --type flag to opportunistic or proactive.

gcloud compute instance-groups managed rolling-action start-update INSTANCE_GROUP_NAME \
    --version=template=NEW_TEMPLATE \
    --type=TYPE

You can also use the beta update command and include the --update-policy-type flag.

gcloud beta compute instance-groups managed update INSTANCE_GROUP_NAME \
    --update-policy-type=TYPE

Replace the following:

REST

Call the patch method on a zonal or regional MIG resource.

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

{
  "updatePolicy": {
    "type": "TYPE" # Choose an opportunistic or proactive update
  },
  "versions": [{
    "instanceTemplate": "global/instanceTemplates/NEW_TEMPLATE",
    }]
}

Replace the following:

To learn more about setting a new template and then applying that template to new and existing VMs in a MIG, see the following pages:

Check your group's update policy type

You can view your MIG's currently configured update policy type ("opportunistic" or "proactive") and other update policy settings by using the gcloud CLI or REST.

gcloud

Use the describe command and include the --format flag to only list the updatePolicy settings.

gcloud beta compute instance-groups managed describe INSTANCE_GROUP_NAME \
    --format="(updatePolicy)"
REST

Make a GET request on a zonal or regional MIG and check the updatePolicy field.

GET https://compute.googleapis.com/compute/beta/projects/PROJECT_ID/regions/REGION/instanceGroupManagers/INSTANCE_GROUP_NAME

To change the policy type, see Set up a proactive or an opportunistic update.

Updates for suspended and stopped VMs

If you have suspended and stopped pools of VMs in a MIG, you can selectively (opportunistic) update suspended or stopped VMs like you update other running VMs. If you configure automatic (proactive) updates, the MIG updates the VMs in the following order:

  1. Running, suspended, and stopped VMs
  2. VMs with status SUSPENDING or STOPPING

For an automatic update, the MIG calculates the maximum surge and maximum unavailable based on the target number of running VMs only, and doesn't consider the VMs in the standby pool.

If the automatic update requires replacing of VMs in the group, then the MIG does the following:

  1. Deletes the suspended and stopped VMs.
  2. Creates new VMs with the new instance template.
  3. Performs the initialization process.
  4. Suspends or stops the VMs.

If the automatic update requires only refreshing or restarting of VMs in the group, then the MIG does the following:

  1. Resumes or starts the VMs.
  2. Performs the update on the VMs when they are running.
  3. Performs the initialization process.
  4. Suspends or stops the VMs.

Canary updates

If you want to initiate canary updates in a MIG that has suspended or stopped VMs, the following applies:

Relationship between versions and instanceTemplate fields

If you use REST, we recommend using the instanceGroupManagers.versions and regionInstanceGroupManagers.versions fields to configure instance templates for zonal and regional MIGs.

The legacy instanceTemplate field overlaps in functionality with the versions field because both fields let you specify which instance template the MIG uses to create VMs. However, only the versions field lets you specify an advanced two-template (canary) configuration.

For backward compatibility, MIGs continue to support setting the top-level instanceTemplate field, even though we recommend that you switch to using only the versions field. Using both the top-level instanceTemplate field and the versions field at the same time can lead to ambiguity and confusion.

If you specify both the instanceTemplate field and the versions field when calling the update() or patch() method, there are three possible outcomes:

The versions field, instanceTemplate field, and the get() method

If you only specify one instance template, either through the top-level instanceTemplate field or through the versions field or through both, the get() method returns both fields in its response. This makes the new versions field backward compatible. As long as you specify a single instance template in either of these fields, there is no change to what the get() method returns in the instanceTemplate field.

If the versions field has two instance templates specified, the get() method returns an empty top-level instanceTemplate field. There is no way to unambiguously express a canary, two-instance template configuration in the top-level instanceTemplate field, so the field is not used during a canary update.

The versions field and the setInstanceTemplate() method

For backward compatibility, the setInstanceTemplate() method behaves as it has previously, letting you change the template the MIG uses to create VMs. When you call this method, the versions field is overridden with the instance template specified by the setInstanceTemplate() method.

The setInstanceTemplate() method also sets the updatePolicy to OPPORTUNISTIC. This prevents the MIG from actively deploying an instance template that isn't explicitly specified in the versions field.

What's next

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