Stay organized with collections Save and categorize content based on your preferences.
If you use a regional managed instance group (MIG), you can set that MIG's target distribution shape to one of the following options:
EVEN
distribution, the number of VMs does not differ by more than 1 between any two zones. Recommended for highly available serving workloads.To use reserved VMs in a regional managed instance group, create identical reservations with the same name in each applicable zone. Then, target those reservations by name in the group's instance template.
To help you choose a shape, see the comparison table, use cases, and how distribution shapes work.
Set a target distribution shape when creating your regional MIG or update the target shape of an existing regional MIG.
Before you beginSelect the tab for how you plan to use the samples on this page:
ConsoleWhen you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloudInstall the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update
.To use the Terraform samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.
Install the Google Cloud CLI.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update
.
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
For more information, see Set up authentication for a local development environment.
RESTTo use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
Install the Google Cloud CLI.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
If you specify resources in your MIG's instance template or stateful configuration that are not available in all selected zones, the following limitations apply:
BALANCED
, ANY
, or ANY_SINGLE_ZONE
.To set the target distribution shape to BALANCED
or ANY_SINGLE_ZONE
, you must disable proactive instance redistribution.
BALANCED
or EVEN
.If you set the target distribution shape to BALANCED
, ANY
, or ANY_SINGLE_ZONE
, the following limitations apply:
SUBSTITUTE
replacement method will try to create the new updated instances in the same zone as the outdated machines, even if the zone doesn't have resources to accommodate the requirements of the new version. To mediate this behavior, you can delete the outdated VMs from the constrained zone, then increase the group size by the number of the deleted VMs. The group creates instances from the latest template in zones where capacity is available.If you set the target distribution shape to ANY_SINGLE_ZONE
and the group has existing VMs in a single zone, you can create additional VMs in that zone only. If you want to use a different zone, you must first scale in the group to zero VMs.
If you need to provision a group of sole-tenant VMs, you must set the MIG's target distribution shape to EVEN
. Create your node groups in the same zones as the MIG's zones and set the MIG's node affinities in the MIG's instance template.
BALANCED
, ANY
, or ANY_SINGLE_ZONE
, the MIG might create VMs outside of your sole-tenant nodes.ANY
or ANY_SINGLE_ZONE
, you cannot use autoscaling. You must set the target distribution shape to EVEN
or BALANCED
to be able to turn on autoscaling.
To create your group, select its zones, and set its target distribution shape, use the Google Cloud console, the gcloud CLI, Terraform, or REST.
Permissions required for this taskTo perform this task, you must have the following permissions:
regionInstanceGroupManagers.insert
method.Choose a region and select the zones you want to use.
Choose a target distribution shape.
Continue with the rest of the MIG creation process.
Use the gcloud compute instance-groups managed create
command and include the --target-distribution-shape
flag.
gcloud compute instance-groups managed create INSTANCE_GROUP_NAME \ --template TEMPLATE \ --size SIZE \ --region REGION \ --zones ZONES \ --target-distribution-shape SHAPE
Replace the following:
INSTANCE_GROUP_NAME
: the name of the instance group.TEMPLATE
: the name of the instance template to use for the group.SIZE
: the target size of the instance group.REGION
: the region where you want your group.ZONES
(optional): a list of zones in the region where you want to deploy VM instances. By default, Compute Engine selects three zones for you.
If you want your MIG to be able to use all zones in the region, specify all the available zones. You can get a list of zones in region with the following command:
gcloud compute zones list --filter=region:REGION
--format='list(NAME)'
Note that you cannot update a regional MIG to use different zones after it is created.
SHAPE
: the target distribution shape. This can be one of the following values:
even
(default): the group creates and deletes VMs to achieve and maintain the same number of VMs across the selected zones. In an EVEN
distribution, the number of VMs does not differ by more than 1 between any two zones. Recommended for highly available serving workloads.balanced
: the group prioritizes creation of VMs in zones where resources are available, while distributing VMs as evenly as possible across selected zones to minimize the impact of zonal failure. Recommended for highly available serving or batch workloads.any
: the group picks zones for creating VM instances to fulfill the requested number of VMs within present resource constraints and to maximize utilization of unused zonal reservations. Recommended for batch workloads that do not require high availability.any-single-zone
: the group creates all VM instances within a single zone. The zone is chosen based on hardware support, current resource and quota availability, and matching reservations. Recommended in combination with a compact instance placement policy for workloads that require extensive communication between VMs.For example, to create a regional MIG with a balanced target distribution shape, set the --target-distribution-shape
flag to balanced
.
gcloud compute instance-groups managed create example-rmig \ --template example-template \ --size 30 \ --zones us-east1-b,us-east1-c \ --target-distribution-shape balanced \ --instance-redistribution-type noneTerraform
If you haven't already created an instance template, which specifies the machine type, boot disk image, network, and other VM properties that you want for each VM in your MIG, create an instance template.
To create a regional MIG, use the google_compute_region_instance_group_manager
resource.
The following example creates a regional MIG with BALANCED
target distribution shape.
To learn how to apply or remove a Terraform configuration, see Basic Terraform commands.
RESTCall the regionInstanceGroupManagers.insert
method. In the request body, include the distributionPolicy
property, and set its targetShape
field.
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceGroupManagers { "name": INSTANCE_GROUP_NAME, "instanceTemplate": "global/instanceTemplates/TEMPLATE", "targetSize": SIZE, "distributionPolicy": { "zones": [ {"zone": "zones/ZONE1"}, {"zone": "zones/ZONE2"}, {"zone": "zones/ZONE3"}, ], "targetShape": "SHAPE" } }
Replace the following:
PROJECT_ID
: the project ID for this request.REGION
: the region for the instance group.INSTANCE_GROUP_NAME
: the name of the instance group.TEMPLATE
: the name of the instance template to use for the instance group.SIZE
: the target size of the instance group.ZONE
: the name of a zone in the region where you want to deploy VM instances.
regions.get
method.SHAPE
: the target distribution shape. This can be one of the following values:
EVEN
(default): the group creates and deletes VMs to achieve and maintain the same number of VMs across the selected zones. In an EVEN
distribution, the number of VMs does not differ by more than 1 between any two zones. Recommended for highly available serving workloads.BALANCED
: the group prioritizes creation of VMs in zones where resources are available, while distributing VMs as evenly as possible across selected zones to minimize the impact of zonal failure. Recommended for highly available serving or batch workloads.ANY
: the group picks zones for creating VM instances to fulfill the requested number of VMs within present resource constraints and to maximize utilization of unused zonal reservations. Recommended for batch workloads that do not require high availability.ANY_SINGLE_ZONE
: the group creates all VM instances within a single zone. The zone is chosen based on hardware support, current resource and quota availability, and matching reservations. Recommended in combination with a compact instance placement policy for workloads that require extensive communication between VMs.You can change the target distribution shape in an existing regional MIG but with the following limitations:
BALANCED
or ANY_SINGLE_ZONE
, you must first disable proactive redistribution.EVEN
and if the current distribution of instances is uneven, you must first disable proactive redistribution.EVEN
and you want to re-enable proactive redistribution, you must first manually rebalance the group.EVEN
but your instance template specifies resources that are not supported in all selected zones, you must first update the group's instance template to one that is supported in all selected zones.To perform this task, you must have the following permissions:
compute.instanceGroupManagers.update
on the instance groupUse the gcloud compute instance-groups managed update
command and include the --target-distribution-shape
flag.
gcloud compute instance-groups managed update INSTANCE_GROUP_NAME \ --target-distribution-shape SHAPE
Replace the following:
INSTANCE_GROUP_NAME
: the name of the instance group.SHAPE
: the target distribution shape. This can be one of the following values:
even
(default): the group creates and deletes VMs to achieve and maintain the same number of VMs across the selected zones. In an EVEN
distribution, the number of VMs does not differ by more than 1 between any two zones. Recommended for highly available serving workloads.balanced
: the group prioritizes creation of VMs in zones where resources are available, while distributing VMs as evenly as possible across selected zones to minimize the impact of zonal failure. Recommended for highly available serving or batch workloads.any
: the group picks zones for creating VM instances to fulfill the requested number of VMs within present resource constraints and to maximize utilization of unused zonal reservations. Recommended for batch workloads that do not require high availability.any-single-zone
: the group creates all VM instances within a single zone. The zone is chosen based on hardware support, current resource and quota availability, and matching reservations. Recommended in combination with a compact instance placement policy for workloads that require extensive communication between VMs.Call the regionInstanceGroupManagers.patch
method. In the request body, include the distributionPolicy
property, and set its targetShape
field.
PATCH https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceGroupManagers/INSTANCE_GROUP_NAME { "distributionPolicy": { "targetShape": "SHAPE" } }
Replace the following:
PROJECT_ID
: the project ID for this request.REGION
: the region for the instance group.INSTANCE_GROUP_NAME
: the name of the instance group.SHAPE
: the target distribution shape. This can be one of the following values:
EVEN
(default): the group creates and deletes VMs to achieve and maintain the same number of VMs across the selected zones. In an EVEN
distribution, the number of VMs does not differ by more than 1 between any two zones. Recommended for highly available serving workloads.BALANCED
: the group prioritizes creation of VMs in zones where resources are available, while distributing VMs as evenly as possible across selected zones to minimize the impact of zonal failure. Recommended for highly available serving or batch workloads.ANY
: the group picks zones for creating VM instances to fulfill the requested number of VMs within present resource constraints and to maximize utilization of unused zonal reservations. Recommended for batch workloads that do not require high availability.ANY_SINGLE_ZONE
: the group creates all VM instances within a single zone. The zone is chosen based on hardware support, current resource and quota availability, and matching reservations. Recommended in combination with a compact instance placement policy for workloads that require extensive communication between VMs.To perform this task, you must have the following permissions:
compute.instanceGroupManagers.get
on the instance groupRun the gcloud compute instance-groups managed describe
command.
gcloud compute instance-groups managed describe INSTANCE_GROUP_NAME \ --region REGION
The command returns the group's details, including the distributionPolicy.targetShape
field:
... distributionPolicy: targetShape: BALANCED zones: - zone: https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-f ... name: my-group region: https://www.googleapis.com/compute/v1/projects/my-project/regions/us-central1 ...REST
Construct a GET
request to the regionInstanceGroupManagers.get
method.
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceGroupManagers/INSTANCE_GROUP_NAME
Replace the following:
PROJECT_ID
: the project ID for this requestREGION
: the region for the instance groupINSTANCE_GROUP_NAME
: the name of the instance groupThe target distribution shape is returned in the distributionPolicy.targetShape
field. For example:
{ "name": "my-instance-group", "distributionPolicy": { "targetShape": "BALANCED", }, "targetSize": 50, ... }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."],[[["Regional Managed Instance Groups (MIGs) allow you to choose a target distribution shape that determines how VMs are distributed across zones, with options including EVEN, BALANCED, ANY, and ANY_SINGLE_ZONE, each recommended for different workload types."],["The `EVEN` distribution shape aims to maintain an equal number of VMs in each zone, the `BALANCED` prioritizes VM creation where resources are available while keeping an even distribution, the `ANY` focuses on fulfilling the requested number of VMs with current constraints, and the `ANY_SINGLE_ZONE` only creates VMs within a single zone."],["You can create a new regional MIG with a specified target distribution shape by using the Google Cloud console, the `gcloud` CLI, Terraform, or REST API, allowing you to configure zones and the distribution policy during group creation."],["Existing regional MIGs can have their target distribution shape updated, however there are certain limitations for changing the target distribution shape to `BALANCED`, `ANY_SINGLE_ZONE`, or `EVEN`, like first disabling proactive redistribution."],["Viewing the currently configured instance distribution policy can be done via the console, `gcloud` CLI or REST API, which allows the user to see the target distribution shape and zones."]]],[]]
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