Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Puedes detener, iniciar y reiniciar las VMs para admitir el ciclo de vida de tus aplicaciones. Por ejemplo, es posible que desees cambiar la cantidad de unidades centrales de procesamiento virtuales (vCPUs) asignadas o la cantidad de memoria asignada a una VM. Debes detener la VM antes de editar la configuración. Cuando termines, debes alternar el estado de energía para aplicar los cambios. En esta página, se proporcionan instrucciones para detener, iniciar y reiniciar tus VMs en esos procesos.
Antes de comenzar
Para usar los comandos de la interfaz de línea de comandos (CLI) de gdcloud, asegúrate de haber descargado, instalado y configurado la CLI de gdcloud.
Todos los comandos de Distributed Cloud usan la CLI de gdcloud o kubectl y requieren un entorno de sistema operativo (SO).
Obtén la ruta de acceso del archivo kubeconfig
Para ejecutar comandos en el servidor de la API de Management, asegúrate de tener los siguientes recursos:
Accede y genera el archivo kubeconfig para el servidor de la API de Management si no tienes uno.
Usa la ruta de acceso al archivo kubeconfig del servidor de la API de administración para reemplazar MANAGEMENT_API_SERVER en estas instrucciones.
Para realizar las tareas que se indican en esta página, debes tener el rol de administrador de la VM del proyecto. Sigue los pasos para verificar o para que el administrador de IAM del proyecto te asigne el rol de administrador de máquinas virtuales del proyecto (project-vm-admin) en el espacio de nombres del proyecto en el que reside la VM.
Para las operaciones de VM con la consola de GDC o la CLI de gdcloud, pídele a tu administrador de IAM del proyecto que te asigne el rol de administrador de máquinas virtuales del proyecto y el rol de visualizador del proyecto (project-viewer).
Detén una VM
Cuando detienes una máquina virtual (VM), el hipervisor desasigna todos los recursos asociados con la instancia. La VM se cerró.
Detén una VM que está en estado de ejecución con la consola de GDC o kubectl.
Console
En el menú de navegación, haz clic en Virtual Machines > Instances.
En la lista de VMs, selecciona la casilla de verificación de la VM en ejecución que deseas detener.
Haz clic en Detener.
En el diálogo de confirmación, haz clic en Detener.
Busca el campo runningState en el spec de la VM y cambia el valor del campo a Stopped. Si runningState no está en spec, agrégalo y establece el valor en Stopped.runningStatespec
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 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."]]