Stay organized with collections
Save and categorize content based on your preferences.
Deleting a virtual machine (VM) removes the VM and its associated resources from
your project. If you don't want to delete an instance, you can temporarily stop
it. See Stop and start a VM for those instructions.
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.
Request permissions and access
To perform the tasks listed in this page, you must have the Project
VirtualMachine Admin role. Follow the steps to
verify
that you have 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.
Delete a VM
Delete a VM by using the GDC console or kubectl. The VM must not be
in a terminating or unknown state.
Console
In the navigation menu, click Virtual Machines > Instances.
In the list of VMs, select the checkbox for the VM that you want to delete.
[[["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\u003eDeleting a VM removes it and its resources from your project, with an option to stop it temporarily instead.\u003c/p\u003e\n"],["\u003cp\u003eUsing the \u003ccode\u003egdcloud\u003c/code\u003e or \u003ccode\u003ekubectl\u003c/code\u003e CLI requires prior installation, configuration, and an operating system environment.\u003c/p\u003e\n"],["\u003cp\u003eAccessing the Management API server requires a kubeconfig file, which can be generated by following provided instructions.\u003c/p\u003e\n"],["\u003cp\u003eTo delete a VM, ensure the user has the Project VirtualMachine Admin role and optionally the Project Viewer role, and the VM must not be in a terminating or unknown state.\u003c/p\u003e\n"],["\u003cp\u003eVMs can be deleted through either the GDC console or the \u003ccode\u003egdcloud\u003c/code\u003e/\u003ccode\u003ekubectl\u003c/code\u003e CLI, with specific commands and variable replacements provided for the CLI options.\u003c/p\u003e\n"]]],[],null,["# Delete VMs\n\nDeleting a virtual machine (VM) removes the VM and its associated resources from\nyour project. If you don't want to delete an instance, you can temporarily stop\nit. See [Stop and start a VM](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vms/manage-vms/operations-and-lifecycle/start-and-stop-vm) for those instructions.\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\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\n[verify](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vms/preparation#verify-user-access)\nthat you have 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.\n\nDelete a VM\n-----------\n\nDelete a VM by using the GDC console or `kubectl`. The VM must not be\nin a terminating or unknown state. \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 VM that you want to delete.\n\n3. Click **Delete**.\n\n4. In the confirmation dialog, click **Delete**.\n\n### gdcloud\n\nTo delete a VM: \n\n gdcloud compute instances delete \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. Delete the VM:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER\u003c/var\u003e delete virtualmachines.virtualmachine.gdc.goog \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e -n \u003cvar translate=\"no\"\u003eNAMESPACE_NAME\u003c/var\u003e\n\n2. Replace \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e and \u003cvar translate=\"no\"\u003eNAMESPACE_NAME\u003c/var\u003e\n with the name and namespace, respectively, of the VM.\n\n3. Verify that you've deleted the VM:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eMANAGEMENT_API_SERVER\u003c/var\u003e get virtualmachines.virtualmachine.gdc.goog \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e -n \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003e\u003ccode translate=\"no\" dir=\"ltr\"\u003ePROJECT\u003c/code\u003e\u003c/var\u003e with the VM project name."]]