Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questo documento descrive come visualizzare la configurazione della flessibilità delle istanze in un gruppo di istanze gestite (MIG) e i tipi di macchine utilizzati da ogni VM del gruppo.
Dopo aver aggiunto o apportato modifiche alla flessibilità dell'istanza in un MIG, puoi eseguire le seguenti operazioni:
Visualizza i tipi di macchina utilizzati da ogni VM per assicurarti che il tipo di macchina che vuoi rimuovere da una selezione di istanze non venga utilizzato da nessuna VM o per controllare i diversi tipi di macchina utilizzati nel MIG.
Prima di iniziare
Se non l'hai ancora fatto, configura l'autenticazione.
L'autenticazione è
il processo di verifica dell'identità per poter accedere a Google Cloud servizi e API.
Per eseguire codice o esempi da un ambiente di sviluppo locale, puoi autenticarti su
Compute Engine selezionando una delle seguenti opzioni:
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
Installa Google Cloud CLI.
Dopo l'installazione,
inizializza Google Cloud CLI eseguendo il seguente comando:
Nella colonna Nome, fai clic sul nome del MIG di cui vuoi
visualizzare la configurazione della flessibilità dell'istanza.
Si apre la pagina di riepilogo del gruppo di istanze gestite.
Fai clic sulla scheda Dettagli.
Nella sezione Flessibilità dell'istanza, la tabella Selezioni istanze
mostra il nome, il ranking e i tipi di macchina di una selezione. Se il MIG non ha configurato la flessibilità dell'istanza, la sezione
Flessibilità dell'istanza non viene mostrata.
gcloud
Per visualizzare la configurazione della flessibilità dell'istanza, utilizza il
comando instance-groups managed describe.
Includi il flag --format per filtrare le
proprietà instanceFlexibilityPolicy.instanceSelections.
Se per un MIG non è configurata la flessibilità dell'istanza, l'output restituisce null.
Sostituisci quanto segue:
INSTANCE_GROUP_NAME: il nome del MIG di cui
vuoi visualizzare la configurazione della flessibilità dell'istanza.
REGION: la regione in cui si trova il MIG.
REST
Per visualizzare la configurazione della flessibilità dell'istanza, utilizza il metodo regionInstanceGroupManagers.get.
Includi il parametro fields nell'URL della richiesta per filtrare le proprietà instanceFlexibilityPolicy.instanceSelections.
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceGroupManagers/INSTANCE_GROUP_NAME?fields=instanceFlexibilityPolicy.instanceSelections
Nella colonna Nome, fai clic sul nome del gruppo di istanze gestite in cui vuoi visualizzare
i tipi di macchina utilizzati da ogni VM.
Si apre la pagina Panoramica del gruppo di istanze gestite, che elenca tutte le VM del gruppo, i relativi tipi di macchine e altri dettagli.
gcloud
Per visualizzare i tipi di macchine utilizzati da ogni VM in un MIG, elenca le VM utilizzando il
comando instance-groups managed list-instances e includi il flag --format per filtrare il
campo propertiesFromFlexibilityPolicy.machineType. Puoi anche filtrare
altri campi in base alle necessità.
INSTANCE_GROUP_NAME: il nome del MIG di cui
vuoi visualizzare la configurazione della flessibilità dell'istanza.
REST
Per visualizzare i tipi di macchine utilizzati da ogni VM in un MIG, elenca le VM utilizzando il
metodo listManagedInstances
e controlla il campo propertiesFromFlexibilityPolicy.machineType nella
risposta.
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceGroupManagers/INSTANCE_GROUP_NAME/listManagedInstances
Di seguito è riportato un output di esempio. Cerca il campo propertiesFromFlexibilityPolicy in cui è impostato il campo machineType di una VM.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-08-19 UTC."],[[["\u003cp\u003eThis document provides instructions on how to view the instance flexibility configuration of a managed instance group (MIG).\u003c/p\u003e\n"],["\u003cp\u003eYou can verify if instance flexibility has been applied to a MIG or if it already has it configured.\u003c/p\u003e\n"],["\u003cp\u003eThe content explains how to check the machine types used by each virtual machine (VM) within a MIG, ensuring desired machine types are not in use, or to review all the used ones.\u003c/p\u003e\n"],["\u003cp\u003eInstructions are available for using the Google Cloud Console, gcloud command-line tool, and REST API to access this information.\u003c/p\u003e\n"]]],[],null,["# View instance flexibility\n\n*** ** * ** ***\n\nThis document describes how to view the instance flexibility configuration in a\nmanaged instance group (MIG) and the machine types used by each VM in the group.\n\nAfter you add or make changes to instance flexibility in a MIG, you can do the\nfollowing:\n\n- [View the instance flexibility configuration](#view_the_instance_flexibility_configuration)\n to verify if a configuration has been applied or to check if a MIG already has\n instance flexibility.\n\n- [View the machine types used by each VM](#view_the_machine_types_used_by_each_vm)\n to make sure that the machine type that you want to remove from an instance\n selection is not used by any VM or to check the different machine types used\n in the MIG.\n\nBefore you begin\n----------------\n\n- If you haven't already, set up [authentication](/compute/docs/authentication). Authentication verifies your identity 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:\n\n Select the tab for how you plan to use the samples on this page: \n\n ### Console\n\n\n When you use the Google Cloud console to access Google Cloud services and\n APIs, you don't need to set up authentication.\n\n ### gcloud\n\n 1.\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n After installation,\n [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command:\n\n ```bash\n gcloud init\n ```\n\n\n If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n 2. [Set a default region and zone](/compute/docs/gcloud-compute#set_default_zone_and_region_in_your_local_client).\n\n ### REST\n\n\n To use the REST API samples on this page in a local development environment, you use the\n credentials you provide to the gcloud CLI.\n 1. [Install](/sdk/docs/install) the Google Cloud CLI. After installation, [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command: \n\n ```bash\n gcloud init\n ```\n 2. If you're using an external identity provider (IdP), you must first [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n\n For more information, see\n [Authenticate for using REST](/docs/authentication/rest)\n in the Google Cloud authentication documentation.\n\nView the instance flexibility configuration\n-------------------------------------------\n\n### Console\n\n1. In the Google Cloud console, go to the **Instance groups** page.\n\n [Go to Instance groups](https://console.cloud.google.com/compute/instanceGroups)\n\n \u003cbr /\u003e\n\n2. In the **Name** column, click the name of the MIG of which you want to\n view the instance flexibility configuration.\n\n The overview page of the MIG opens.\n3. Click the **Details** tab.\n\n In the **Instance flexibility** section, the **Instance selections**\n table shows the instance selection name, rank, and the machine types in\n a selection. If the MIG doesn't have instance flexibility configured, the\n **Instance flexibility** section is not shown.\n\n### gcloud\n\nTo view the instance flexibility configuration, use the\n[`instance-groups managed describe` command](/sdk/gcloud/reference/compute/instance-groups/managed/describe).\nInclude the `--format` flag to filter the\n`instanceFlexibilityPolicy.instanceSelections` properties. \n\n```\n gcloud compute instance-groups managed describe INSTANCE_GROUP_NAME \\\n --region REGION \\\n --format=\"json(instanceFlexibilityPolicy.instanceSelections)\"\n```\n\nThe following is a sample output: \n\n```\n{\n \"instanceFlexibilityPolicy\": {\n \"instanceSelections\": {\n \"instance-selection-1\": {\n \"machineTypes\": [\n \"n1-standard-16\",\n \"n2-standard-16\",\n \"e2-standard-16\"\n ],\n \"rank\": 1\n }\n }\n }\n}\n```\n\nIf a MIG doesn't have instance flexibility configured, the output returns\n`null`.\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eINSTANCE_GROUP_NAME\u003c/var\u003e: the name of the MIG of which you want to view the instance flexibility configuration.\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e: the region where the MIG is located.\n\n### REST\n\nTo view the instance flexibility configuration, use the\n[`regionInstanceGroupManagers.get` method](/compute/docs/reference/rest/v1/regionInstanceGroupManagers/get).\nInclude the `fields` parameter in the request URL to filter the\n`instanceFlexibilityPolicy.instanceSelections` properties. \n\n```\n GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceGroupManagers/INSTANCE_GROUP_NAME?fields=instanceFlexibilityPolicy.instanceSelections\n```\n\nThe following is a sample output: \n\n```\n{\n \"instanceFlexibilityPolicy\": {\n \"instanceSelections\": {\n \"instance-selection-1\": {\n \"machineTypes\": [\n \"n1-standard-16\",\n \"n2-standard-16\",\n \"e2-standard-16\"\n ],\n \"rank\": 1\n }\n }\n }\n}\n```\n\nIf a MIG doesn't have instance flexibility configured, the output returns\n`null`.\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: your [project ID](/resource-manager/docs/creating-managing-projects#identifying_projects).\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e: the region where the MIG is located.\n- \u003cvar translate=\"no\"\u003eINSTANCE_GROUP_NAME\u003c/var\u003e: the name of the MIG of which you want to view the instance flexibility configuration.\n\nView the machine types used by each VM\n--------------------------------------\n\n### Console\n\n1. In the Google Cloud console, go to the **Instance groups** page.\n\n [Go to Instance groups](https://console.cloud.google.com/compute/instanceGroups)\n\n \u003cbr /\u003e\n\n2. In the **Name** column, click the name of the MIG in which you want view\n the machine types used by each VM.\n\n The **Overview** page of the MIG opens, which lists all VMs in the group,\n their machine types, and other details.\n\n### gcloud\n\nTo view the machine types used by each VM in a MIG, list the VMs using the\n[`instance-groups managed list-instances` command](/sdk/gcloud/reference/compute/instance-groups/managed/list-instances) and include the `--format` flag to filter the\n`propertiesFromFlexibilityPolicy.machineType` field. You can also filter\nother fields as needed. \n\n```\n gcloud compute instance-groups managed list-instances INSTANCE_GROUP_NAME \\\n --region REGION \\\n --format='(name,instanceStatus,currentAction,propertiesFromFlexibilityPolicy.machineType,lastAttempt.errors.errors)'\n```\n\nThe following is a sample output: \n\n```\nNAME: example-mig-0md2\nSTATUS: RUNNING\nACTION: NONE\nMACHINE_TYPE: n1-standard-16\nLAST_ERROR:\n\nNAME: example-mig-vbgg\nSTATUS: RUNNING\nACTION: NONE\nMACHINE_TYPE: n1-standard-16\nLAST_ERROR:\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e: the region where the MIG is located.\n- \u003cvar translate=\"no\"\u003eINSTANCE_GROUP_NAME\u003c/var\u003e: the name of the MIG of which you want to view the instance flexibility configuration.\n\n### REST\n\nTo view the machine types used by each VM in a MIG, list the VMs using the\n[`listManagedInstances` method](/compute/docs/reference/rest/v1/regionInstanceGroupManagers/listManagedInstances)\nand check the `propertiesFromFlexibilityPolicy.machineType` field in the\nresponse. \n\n```\n POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceGroupManagers/INSTANCE_GROUP_NAME/listManagedInstances\n```\n\nThe following is a sample output; look for the\n`propertiesFromFlexibilityPolicy` field in which the `machineType` field of\na VM is set. \n\n```\n{\n \"managedInstances\": [\n {\n \"instance\": \"https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-b/instances/example-mig-0md2\",\n \"instanceStatus\": \"RUNNING\",\n \"id\": \"2656095434923471959\",\n \"version\": {\n \"instanceTemplate\": \"https://www.googleapis.com/compute/v1/projects/example-project/global/instanceTemplates/example-instance-template\"\n },\n \"targetStatus\": \"RUNNING\",\n \"name\": \"example-mig-0md2\",\n \"propertiesFromFlexibilityPolicy\": {\n \"machineType\": \"n1-standard-16\"\n }\n },\n {\n \"instance\": \"https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-b/instances/example-mig-vbgg\",\n \"instanceStatus\": \"RUNNING\",\n \"currentAction\": \"NONE\",\n \"id\": \"9171259522409694366\",\n \"version\": {\n \"instanceTemplate\": \"https://www.googleapis.com/compute/v1/projects/example-project/global/instanceTemplates/example-instance-template\"\n },\n \"targetStatus\": \"RUNNING\",\n \"name\": \"example-mig-vbgg\",\n \"propertiesFromFlexibilityPolicy\": {\n \"machineType\": \"n1-standard-16\"\n }\n }\n ]\n}\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: your [project ID](/resource-manager/docs/creating-managing-projects#identifying_projects).\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e: the region where the MIG is located.\n- \u003cvar translate=\"no\"\u003eINSTANCE_GROUP_NAME\u003c/var\u003e: the name of the MIG of which you want to view the instance flexibility configuration.\n\nWhat's next\n-----------\n\n- [Change or remove instance flexibility configuration](/compute/docs/instance-groups/change-or-remove-instance-flexibility-configuration).\n\n- If your MIG doesn't have instance flexibility, [add instance flexibility](/compute/docs/instance-groups/configure-instance-flexibility)."]]