Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Puoi arrestare, avviare e riavviare le VM per supportare il ciclo di vita delle tue
applicazioni. Ad esempio, potresti voler modificare il numero di unità di elaborazione centrale virtuali (vCPU) assegnate o la quantità di memoria allocata a una VM. Devi arrestare la VM prima di modificare la configurazione. Al termine,
devi riavviare il dispositivo per applicare le modifiche. Questa pagina fornisce istruzioni
per arrestare, avviare e riavviare le VM in questi processi.
Prima di iniziare
Per utilizzare i comandi dell'interfaccia a riga di comando (CLI) gdcloud, assicurati di aver scaricato, installato e configurato la CLI gdcloud.
Tutti i comandi per Distributed Cloud utilizzano la CLI gdcloud o
kubectl e richiedono un ambiente del sistema operativo.
Recupera il percorso del file kubeconfig
Per eseguire comandi sul server API Management, assicurati di disporre delle seguenti risorse:
Accedi e genera il file kubeconfig per il server API Management se non ne hai uno.
Utilizza il percorso del file kubeconfig del server API Management per sostituire
MANAGEMENT_API_SERVER in queste istruzioni.
Per eseguire le attività elencate in questa pagina, devi disporre del ruolo Amministratore
macchina virtuale progetto. Segui i passaggi per verificare o chiedere all'amministratore IAM progetto di assegnarti il ruolo Amministratore VirtualMachine progetto (project-vm-admin) nello spazio dei nomi del progetto in cui si trova la VM.
Per le operazioni sulle VM che utilizzano la console GDC o gcloud CLI, chiedi all'amministratore IAM del progetto di assegnarti sia il ruolo Amministratore VM del progetto sia il ruolo Visualizzatore progetto (project-viewer).
Arresta una VM
Quando arresti una macchina virtuale (VM), l'hypervisor dealloca tutte le risorse
associate all'istanza. La VM è arrestata.
Arresta una VM in stato di esecuzione utilizzando la console GDC o
kubectl.
Console
Nel menu di navigazione, fai clic su Virtual Machines > Instances.
Nell'elenco delle VM, seleziona la casella di controllo relativa alla VM in esecuzione che vuoi
arrestare.
Fai clic su Arresta.
Nella finestra di dialogo di conferma, fai clic su Interrompi.
Cerca il campo runningState in spec della VM e modifica il valore del campo in Stopped. Se runningState non è in spec, aggiungi runningState a spec e imposta il valore su Stopped.
[[["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-09-04 UTC."],[[["\u003cp\u003eThis guide details how to manage the lifecycle of virtual machines (VMs) by stopping, starting, and restarting them to support application needs.\u003c/p\u003e\n"],["\u003cp\u003eYou can modify a VM's configuration, such as vCPU count or memory, but the VM must be stopped before these changes can be applied and then must be power cycled for them to take effect.\u003c/p\u003e\n"],["\u003cp\u003eThe process of stopping a VM involves deallocating all resources associated with the instance, whereas starting a VM returns it from a stopped state to running.\u003c/p\u003e\n"],["\u003cp\u003eRestarting a VM resets it to its initial state and wipes the memory contents, essentially rebooting the system.\u003c/p\u003e\n"],["\u003cp\u003eTo perform these operations, you will need the Project VirtualMachine Admin role and use either the GDC console, \u003ccode\u003egdcloud\u003c/code\u003e CLI, or \u003ccode\u003ekubectl\u003c/code\u003e CLI.\u003c/p\u003e\n"]]],[],null,["# Start and stop a VM\n\nYou can stop, start, and restart VMs to support the lifecycle of your\napplications. For example, you might want to change the number of assigned\nvirtual centralized processing units (vCPUs) or the amount of memory allocated to\na VM. You must stop the VM before you edit the configuration. After you finish,\nyou must cycle the power state to apply the changes. This page provides instructions\nto stop, start, and restart your VMs in such processes.\n\nBefore you begin\n----------------\n\nTo use `gdcloud` command-line interface (CLI) commands, ensure that you have downloaded, installed,\nand configured the [`gdcloud` CLI](/distributed-cloud/hosted/docs/latest/gdch/resources/gdcloud-overview).\nAll commands for Distributed Cloud use the `gdcloud` or\n`kubectl` CLI, and require an operating system (OS) environment.\n\n### Get the kubeconfig file path\n\nTo run commands against the Management API server, ensure you have the following\nresources:\n\n1. [Sign in and generate](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/iam/sign-in#cli) the\n kubeconfig file for the Management API server if you don't have one.\n\n2. Use the path to the kubeconfig file of the Management API server to replace\n \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER\u003c/var\u003e in these instructions.\n\nIf you want to minimize your VM start up time, follow the directions in\n[Minimize the VM start time](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vms/manage-vms/operations-and-lifecycle/minimize-vm-start)\nbefore you start your VM.\n\n### Request permissions and access\n\nTo perform the tasks listed in this page, you must have the Project\nVirtualMachine Admin role. Follow the steps to either\n[verify](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vms/preparation#verify-user-access)\nor have your Project IAM Admin\n[assign](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/iam/role-bindings)\nyou the Project VirtualMachine Admin (`project-vm-admin`) role in the namespace\nof the project where the VM resides.\n\nFor VM operations using the GDC console or the gdcloud CLI,\nrequest your Project IAM Admin to assign you both the\nProject VirtualMachine Admin role and the Project Viewer (`project-viewer`)\nrole.xs\n\nStop a VM\n---------\n\nWhen you stop a virtual machine (VM), the hypervisor deallocates all resources\nassociated with the instance. The VM is shut down.\n\nStop a VM that's in a running state by using the GDC console or\n`kubectl`. \n\n### Console\n\n1. In the navigation menu, click **Virtual Machines \\\u003e Instances**.\n\n2. In the list of VMs, select the checkbox for the running VM that you want\n to stop.\n\n3. Click **Stop**.\n\n4. In the confirmation dialog, click **Stop**.\n\n### gdcloud\n\nTo stop a VM: \n\n gdcloud compute instances stop \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e --project \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n\n- Replace \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e with the name of the VM.\n- Replace \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e with the name of the GDC project in which the VM lives.\n\n### kubectl\n\n1. Run the following command:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_KUBECONFIG\u003c/var\u003e \\\n edit virtualmachines.virtualmachine.gdc.goog \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e \\\n -n \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n\n2. Look for the field `runningState` in the `spec` of the VM and change the value of the field to `Stopped`. If `runningState` is not in the `spec` add `runningState` to the `spec` and set the value to `Stopped`.\n\n spec:\n runningState: Stopped\n\n3. Verify the status of the VM:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_KUBECONFIG\u003c/var\u003e \\\n get virtualmachines.virtualmachine.gdc.goog \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e \\\n -n \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n\n Use these definitions for the preceding variables.\n\nStart a VM\n----------\n\nStart a VM from a stopped state by using the console or `kubectl`. \n\n### Console\n\n1. In the navigation menu, click **Virtual Machines \\\u003e Instances**.\n\n2. In the list of VMs, select the checkbox for the stopped VM that you want\n to start.\n\n3. Click **Start**.\n\n4. In the confirmation dialog, click **Start**.\n\n### gdcloud\n\nTo start a VM: \n\n gdcloud compute instances start \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e --project \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n\n- Replace \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e with the name of the VM.\n- Replace \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e with the name of the GDC project in which the VM lives.\n\n### kubectl\n\n1. Run the following command:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_KUBECONFIG\u003c/var\u003e \\ \n edit virtualmachines.virtualmachine.gdc.goog \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e \\ \n -n \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n\n2. Look for the field `runningState` in the `spec` of the VM and change the value of the field to `Running`.\n\n spec:\n runningState: Running\n\n3. Verify the VM status:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_KUBECONFIG\u003c/var\u003e \\\n get virtualmachines.virtualmachine.gdc.goog \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e \\\n -n \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n\n Use these definitions for the variables in the example code.\n\nRestart a VM\n------------\n\nWhen you restart a VM, the machine resets to its initial state and the memory\ncontents of the machine are wiped.\n\nRestart a VM that is in a running state by using the console or `kubectl`. \n\n### Console\n\n1. In the navigation menu, click **Virtual Machines \\\u003e Instances**.\n\n2. In the list of VMs, select the checkbox for the running VM that you want\n to restart.\n\n3. Click **Reset**.\n\n4. In the confirmation dialog, click **Reset**.\n\n### gdcloud\n\nTo reset a VM: \n\n gdcloud compute instances reset \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e --project \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n\n- Replace \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e with the name of the VM.\n- Replace \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e with the name of the GDC project in which the VM lives.\n\n### kubectl\n\n1. Get the client certificate and key data, and the Management API server.\n Use these values in the following steps:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_KUBECONFIG\u003c/var\u003e config view --raw -o \\\n jsonpath='{.users[?(@.name ==\"\u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_NAME\u003c/var\u003e-admin\")].user.client-certificate-data}' | \\\n base64 -d \u003e cert\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_KUBECONFIG\u003c/var\u003e config view --raw -o \\\n jsonpath='{.users[?(@.name == \"\u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_NAME\u003c/var\u003e-admin\")].user.client-key-data}' | \\\n base64 -d \u003e key\n export APISERVER=`kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_KUBECONFIG\u003c/var\u003e \\\n config view --raw -o \\\n jsonpath='{.clusters[?(@.name == \"\u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_NAME\u003c/var\u003e\")].cluster.server}'`\n\n2. Make an API request to restart the VM using the `wget` command and specify\n the certificate and key from the previous step:\n\n wget --method=PUT -O- --no-check-certificate --certificate cert --private-key key --content-on-error=on $APISERVER/apis/virtualmachineoperations.gdc.goog/v1/namespaces/\u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e/virtualmachines/\u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e/restart\n\n3. Verify the VM status:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER_KUBECONFIG\u003c/var\u003e \\\n get virtualmachines.virtualmachine.gdc.goog \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e -n \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n\n Use these definitions for the variables in the\n example code."]]