VM Runtime on GDC lets you delete virtual machines (VMs) and their
associated disk resources together or independently. You can choose to delete
both the VM and associated disk resources, only the VM resource, or only the
disk resources. For example, you can delete only the VM and keep its disk to
reuse with another VM.

## Before you begin

To complete this document, you need access to the following resources:

- A VM that runs in one of your clusters. If needed, [create a VM in Google Distributed Cloud](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/quickstart.md.txt).
- The `virtctl` client tool installed as a plugin for `kubectl`. If needed, [install the virtctl client tool](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/quickstart.md.txt#install_the_virtctl_client_tool).

## Delete the VM and disk resources

This option deletes the VM resource and any associated virtual disks.

- Use `kubectl` to delete both the VM and it's associated disk resources:

  ```bash
  kubectl virt delete vm VM_NAME --all
  ```

  Replace `VM_NAME` with the name of the VM that you want to
  delete.

  If you want to check the resources used by the VM that would be deleted,
  specify the `--dry-run` flag together with `--all`.

  If you want to delete the VM without also deleting the disk resource, don't
  include the `--all` flag, as shown in the next section.

## Delete the VM resource

This option only deletes the VM resource. Any associated virtual disks remain
as part of the cluster. This option lets you create another VM and resuse the
disk resource. The lifecycle of the VM can be managed separately to the
lifecycle of the disk resource.

- Use `kubectl` to delete only the VM:

  ```bash
  kubectl virt delete vm VM_NAME
  ```

  Replace `VM_NAME` with the name of the VM that you want to
  delete.

## Delete the VM disk resource

This option deletes a virtual disk resource. If the associated VM still runs in
the cluster, the VM resource isn't deleted. This approach lets you delete a disk
resource that remains if you previously deleted a VM without using the `--all`
parameter.

- Use `kubectl` to delete only the VM's disk resources:

  ```bash
  kubectl virt delete disk DISK_NAME
  ```

  Replace `DISK_NAME` with the name of the disk that you want
  to delete. For example, the default boot disk for a VM is named
  `DISK_NAME-boot-dv`. You can list all existing disks using
  `kubectl get datavolume`.

  If you try to delete a VM's disk before deleting the VM, the disk
  is marked for deletion. The disk is only deleted when you also delete the VM.

## What's next

- [Create and manage disks in Google Distributed Cloud](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/create-manage-disks.md.txt).