VM Runtime on GDC lets you stop, start, and restart virtual
machines (VMs) to manage your application lifecycle. After you edit a VM
configuration to change assigned vCPUs or memory, you must cycle the power
state to apply the changes.

## 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).

## Stop a VM

When you stop a VM, compute resources such as CPU and memory are freed from the
underlying host. The VM is shut down.

To stop a VM that's in a running state, use the following steps.

1. Use `kubectl` to stop a VM:

   ```bash
     kubectl virt stop VM_NAME
   ```

   Replace `VM_NAME` with the name of the VM that you want to
   stop.
2. Check the `STATUS` of your VM:

   ```bash
     kubectl get gvm VM_NAME
   ```

   The following example output shows the VM in a `Stopped` state:

   ```bash
     NAME   STATUS    AGE   IP
     vm1    Stopped   1m    192.168.2.72
   ```

## Start a VM

To start a VM that's in a stopped state, use the following steps.

1. Use `kubectl` to start a VM:

   ```bash
     kubectl virt start VM_NAME
   ```

   Replace `VM_NAME` with the name of the VM that you want
   to start.
2. Check the `STATUS` of your VM:

   ```bash
     kubectl get gvm VM_NAME
   ```

   The following example output shows the VM in a `Running` state:

   ```bash
     NAME   STATUS    AGE   IP
     vm1    Running   1m    192.168.2.72
   ```

## Restart a VM

To restart a VM that's in a running state, use the following steps.

1. Use `kubectl` to restart a VM:

   ```bash
     kubectl virt restart VM_NAME
   ```

   Replace `VM_NAME` with the name of the VM that you want to
   restart.
2. Check the `STATUS` of your VM:

   ```bash
     kubectl get gvm VM_NAME
   ```

   The following example output shows the VM in a `Stopping` state:

   ```bash
     NAME   STATUS    AGE   IP
     vm1    Stopping  7s    192.168.2.72
   ```
3. Check the `STATUS` of your VM again after a minute or two:

   ```bash
     kubectl get gvm VM_NAME
   ```

   After the VM has successfully restarted, the following example output shows
   the VM in a `Running` state again:

   ```bash
     NAME   STATUS    AGE   IP
     vm1    Running   1m    192.168.2.73
   ```

   This example VM uses an ephemeral pod IP address, so the address changes
   when the VM restarts.

## What's next

- [Edit a VM in Google Distributed Cloud](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/edit-vm.md.txt).
- When you no longer need VMs, [Delete a VM in Google Distributed Cloud](https://docs.cloud.google.com/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/delete.md.txt).