Stay organized with collections
Save and categorize content based on your preferences.
You can stop, start, and restart VMs to support the lifecycle of your
applications. For example, you might want to change the number of assigned
virtual centralized processing units (vCPUs) or the amount of memory allocated to
a VM. You must stop the VM before you edit the configuration. After you finish,
you must cycle the power state to apply the changes. This page provides instructions
to stop, start, and restart your VMs in such processes.
Before you begin
To use gdcloud command-line interface (CLI) commands, ensure that you have downloaded, installed,
and configured the gdcloud CLI.
All commands for Distributed Cloud use the gdcloud or
kubectl CLI, and require an operating system (OS) environment.
Get the kubeconfig file path
To run commands against the Management API server, ensure you have the following
resources:
Sign in and generate the
kubeconfig file for the Management API server if you don't have one.
Use the path to the kubeconfig file of the Management API server to replace
MANAGEMENT_API_SERVER in these instructions.
If you want to minimize your VM start up time, follow the directions in
Minimize the VM start time
before you start your VM.
Request permissions and access
To perform the tasks listed in this page, you must have the Project
VirtualMachine Admin role. Follow the steps to either
verify
or have your Project IAM Admin
assign
you the Project VirtualMachine Admin (project-vm-admin) role in the namespace
of the project where the VM resides.
For VM operations using the GDC console or the gdcloud CLI,
request your Project IAM Admin to assign you both the
Project VirtualMachine Admin role and the Project Viewer (project-viewer)
role.xs
Stop a VM
When you stop a virtual machine (VM), the hypervisor deallocates all resources
associated with the instance. The VM is shut down.
Stop a VM that's in a running state by using the GDC console or
kubectl.
Console
In the navigation menu, click Virtual Machines > Instances.
In the list of VMs, select the checkbox for the running VM that you want
to stop.
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.
[[["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-29 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."]]