View instance flexibility


This document describes how to view the instance flexibility configuration in a managed instance group (MIG) and the machine types used by each VM in the group.

After you add or make changes to instance flexibility in a MIG, you can do the following:

Before you begin

  • If you haven't already, then set up authentication. Authentication is the process by which your identity is verified for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:

    Select the tab for how you plan to use the samples on this page:

    Console

    When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.

    gcloud

    1. Install the Google Cloud CLI, then initialize it by running the following command:

      gcloud init
    2. Set a default region and zone.

    REST

    To 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, then initialize it by running the following command:

      gcloud init

    For more information, see Authenticate for using REST in the Google Cloud authentication documentation.

View the instance flexibility configuration

Console

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

    Go to Instance groups

  2. In the Name column, click the name of the MIG of which you want to view the instance flexibility configuration.

    The overview page of the MIG opens.

  3. Click the Details tab.

    In the Instance flexibility section, the Instance selections table shows the instance selection name, rank, and the machine types in a selection. If the MIG doesn't have instance flexibility configured, the Instance flexibility section is not shown.

gcloud

To view the instance flexibility configuration, use the instance-groups managed describe command. Include the --format flag to filter the instanceFlexibilityPolicy.instanceSelections properties.

  gcloud compute instance-groups managed describe INSTANCE_GROUP_NAME \
      --region REGION \
      --format="json(instanceFlexibilityPolicy.instanceSelections)"

The following is a sample output:

{
  "instanceFlexibilityPolicy": {
    "instanceSelections": {
      "instance-selection-1": {
        "machineTypes": [
          "n1-standard-16",
          "n2-standard-16",
          "e2-standard-16"
        ],
        "rank": 1
      }
    }
  }
}

If a MIG doesn't have instance flexibility configured, the output returns null.

Replace the following:

  • INSTANCE_GROUP_NAME: the name of the MIG of which you want to view the instance flexibility configuration.
  • REGION: the region where the MIG is located.

REST

To view the instance flexibility configuration, use the regionInstanceGroupManagers.get method. Include the fields parameter in the request URL to filter the instanceFlexibilityPolicy.instanceSelections properties.

  GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceGroupManagers/INSTANCE_GROUP_NAME?fields=instanceFlexibilityPolicy.instanceSelections

The following is a sample output:

{
  "instanceFlexibilityPolicy": {
    "instanceSelections": {
      "instance-selection-1": {
        "machineTypes": [
          "n1-standard-16",
          "n2-standard-16",
          "e2-standard-16"
        ],
        "rank": 1
      }
    }
  }
}

If a MIG doesn't have instance flexibility configured, the output returns null.

Replace the following:

  • PROJECT_ID: your project ID.
  • REGION: the region where the MIG is located.
  • INSTANCE_GROUP_NAME: the name of the MIG of which you want to view the instance flexibility configuration.

View the machine types used by each VM

Console

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

    Go to Instance groups

  2. In the Name column, click the name of the MIG in which you want view the machine types used by each VM.

    The Overview page of the MIG opens, which lists all VMs in the group, their machine types, and other details.

gcloud

To view the machine types used by each VM in a MIG, list the VMs using the instance-groups managed list-instances command and include the --format flag to filter the propertiesFromFlexibilityPolicy.machineType field. You can also filter other fields as needed.

  gcloud compute instance-groups managed list-instances INSTANCE_GROUP_NAME \
      --region REGION \
      --format='(name,instanceStatus,currentAction,propertiesFromFlexibilityPolicy.machineType,lastAttempt.errors.errors)'

The following is a sample output:

NAME: example-mig-0md2
STATUS: RUNNING
ACTION: NONE
MACHINE_TYPE: n1-standard-16
LAST_ERROR:

NAME: example-mig-vbgg
STATUS: RUNNING
ACTION: NONE
MACHINE_TYPE: n1-standard-16
LAST_ERROR:

Replace the following:

  • REGION: the region where the MIG is located.
  • INSTANCE_GROUP_NAME: the name of the MIG of which you want to view the instance flexibility configuration.

REST

To view the machine types used by each VM in a MIG, list the VMs using the listManagedInstances method and check the propertiesFromFlexibilityPolicy.machineType field in the response.

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

The following is a sample output; look for the propertiesFromFlexibilityPolicy field in which the machineType field of a VM is set.

{
  "managedInstances": [
    {
      "instance": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-b/instances/example-mig-0md2",
      "instanceStatus": "RUNNING",
      "id": "2656095434923471959",
      "version": {
        "instanceTemplate": "https://www.googleapis.com/compute/v1/projects/example-project/global/instanceTemplates/example-instance-template"
      },
      "targetStatus": "RUNNING",
      "name": "example-mig-0md2",
      "propertiesFromFlexibilityPolicy": {
        "machineType": "n1-standard-16"
      }
    },
    {
      "instance": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-b/instances/example-mig-vbgg",
      "instanceStatus": "RUNNING",
      "currentAction": "NONE",
      "id": "9171259522409694366",
      "version": {
        "instanceTemplate": "https://www.googleapis.com/compute/v1/projects/example-project/global/instanceTemplates/example-instance-template"
      },
      "targetStatus": "RUNNING",
      "name": "example-mig-vbgg",
      "propertiesFromFlexibilityPolicy": {
        "machineType": "n1-standard-16"
      }
    }
  ]
}

Replace the following:

  • PROJECT_ID: your project ID.
  • REGION: the region where the MIG is located.
  • INSTANCE_GROUP_NAME: the name of the MIG of which you want to view the instance flexibility configuration.

What's next