This document is intended for application owners that run Google Distributed Cloud. This document shows you how to manage the power state of virtual machines (VMs) that use VM Runtime on GDC.
You can stop, start, and restart VMs as needed to support the lifecycle of your applications. For example, you may want to change the number of assigned vCPUs or amount of memory. After you edit the configuration of your VM, 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 Distributed Cloud.
- The
virtctl
client tool installed as a plugin forkubectl
. If needed, 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.
Use
kubectl
to stop a VM:kubectl virt stop VM_NAME
Replace
VM_NAME
with the name of the VM that you want to stop.Check the
STATUS
of your VM:kubectl get gvm VM_NAME
The following example output shows the VM in a
Stopped
state: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.
Use
kubectl
to start a VM:kubectl virt start VM_NAME
Replace
VM_NAME
with the name of the VM that you want to start.Check the
STATUS
of your VM:kubectl get gvm VM_NAME
The following example output shows the VM in a
Running
state: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.
Use
kubectl
to restart a VM:kubectl virt restart VM_NAME
Replace
VM_NAME
with the name of the VM that you want to restart.Check the
STATUS
of your VM:kubectl get gvm VM_NAME
The following example output shows the VM in a
Stopping
state:NAME STATUS AGE IP vm1 Stopping 7s 192.168.2.72
Check the
STATUS
of your VM again after a minute or two:kubectl get gvm VM_NAME
After the VM has successfully restarted, the following example output shows the VM in a
Running
state again: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 Distributed Cloud.
- When you no longer need VMs, Delete a VM in Google Distributed Cloud.