Delete VMs

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 org admin cluster, ensure you have the following resources:

  1. Locate the org admin cluster name, or ask your Platform Administrator (PA) what the cluster name is.

  2. Sign in and generate the kubeconfig file for the org admin cluster if you don't have one.

  3. Use the path to the kubeconfig file of the org admin cluster to replace ORG_ADMIN_KUBECONFIG 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

  1. In the navigation menu, click Virtual Machines > Instances.

  2. In the list of VMs, select the checkbox for the VM that you want to delete.

  3. Click Delete.

  4. In the confirmation dialog, click Delete.

gdcloud

To delete a VM:

gdcloud compute instances delete VM_NAME --project PROJECT
  • Replace VM_NAME with the name of the VM.
  • Replace PROJECT with the name of the GDC project in which the VM lives.

kubectl

  1. Delete the VM:

    kubectl --kubeconfig ORG_ADMIN_KUBECONFIG delete virtualmachines.virtualmachine.gdc.goog VM_NAME -n NAMESPACE_NAME
    
  2. Replace VM_NAME and NAMESPACE_NAME with the name and namespace, respectively, of the VM.

  3. Verify that you've deleted the VM:

    kubectl --kubeconfig ORG_ADMIN_KUBECONFIG get virtualmachines.virtualmachine.gdc.goog VM_NAME -n PROJECT
    

    Replace PROJECT with the VM project name.