Manage VM Lifecycle

This guide shows you how to manage the lifecycle of virtual machines, including viewing, starting, stopping, updating, and deleting VMs.

List virtual machines

View all VMs in your resource group.

Using the CLI:

evroc compute vm list

Output:

Name       Ready   Reason   VirtualMachineStatus   IP          Public IP
---------- ------- -------- ---------------------- ----------- -----------
myvm       True    Ready    Running                10.0.0.50   203.0.113.10

Using the API:

kubectl get virtualmachines

Or using the short name:

kubectl get evvm

View VM details

Get detailed information about a specific VM.

Using the CLI:

evroc compute vm show myvm

For verbose output with full metadata:

evroc compute vm show myvm --verbose

Using the API:

Brief overview:

kubectl get virtualmachine myvm

Detailed information:

kubectl describe virtualmachine myvm

Full YAML specification:

kubectl get virtualmachine myvm -o yaml

Stop a VM

Stop a running VM. Stopping shuts down the VM, and you can restart it later. Cloud-init does not run again on restart.

Using the CLI:

evroc compute vm update myvm --running=false

Using the API:

Edit the VM spec and set running: false. There are several equivalent ways to achieve this:

  1. Patch the VM:
kubectl patch virtualmachine myvm --type=merge -p '{"spec":{"running":false}}
  1. Edit the VM spec in place, change the value of the running field and save to apply.
kubectl edit virtualmachine myvm
  1. Apply an updated YAML file:
apiVersion: compute.evroclabs.net/v1alpha1
kind: VirtualMachine
metadata:
  name: myvm
spec:
  running: false
  # ... rest of spec unchanged
kubectl apply -f vm.yaml

Start a VM

Start a stopped VM.

Using the CLI:

evroc compute vm update myvm --running=true

Using the API:

Patch:

kubectl patch virtualmachine myvm --type=merge -p '{"spec":{"running":true}}

Or edit the VM spec and set running: true:

kubectl edit virtualmachine myvm

Or apply an updated YAML file with running: true.

Update a VM

You can update certain VM properties after creation.

Supported updates

The following fields can be updated on a running or stopped VM:

  • Running state - Start or stop the VM
  • Public IP - Attach or detach a Public IP
  • Security groups - Add, remove, or replace security groups
  • Disks - Attach additional data disks (requires stop/start for changes to take effect)
  • Placement group - Change placement group (requires VM to be stopped)

Unsupported updates

The following fields cannot be changed after VM creation through the CLI or API:

  • Boot disk
  • Resource profile (CPU, memory, GPU)
  • SSH public keys (via CLI/API - however, you can add additional keys manually within the guest OS after logging in)
  • Cloud-init configuration

Attach or detach a Public IP

Using the CLI:

Attach a Public IP:

evroc compute vm update myvm --public-ip=mypublicip

Detach a Public IP:

evroc compute vm update myvm --public-ip=""

Using the API:

kubectl edit virtualmachine myvm

Update the networking.publicIPv4Address.static.publicIPRef field:

spec:
  networking:
    publicIPv4Address:
      static:
        publicIPRef: mypublicip  # or remove this section entirely to detach

Add or remove security groups

When updating security groups with the CLI, you can either replace the entire list or append to it.

Using the CLI:

Replace all security groups with a new set:

evroc compute vm update myvm --security-group=web-sg --security-group=app-sg

Add security groups to the existing list:

evroc compute vm update myvm --append --security-group=new-sg

Remove a security group by omitting it from the replacement list:

evroc compute vm update myvm --security-group=web-sg  # removes all others

Using the API:

kubectl edit virtualmachine myvm

Update the networking.securityGroups section:

spec:
  networking:
    securityGroups:
      securityGroupMemberships:
        - name: web-sg
        - name: app-sg

Attach additional disks

You can attach additional data disks to a VM. The disk will become available after the next stop/start cycle.

Using the CLI:

evroc compute vm update myvm --append --disk=mydatadisk

Using the API:

kubectl edit virtualmachine myvm

Add the disk to spec.diskRefs:

spec:
  diskRefs:
  - bootFrom: true
    name: mybootdisk
  - bootFrom: false
    name: mydatadisk  # newly added disk

Note: After attaching a disk, you must stop and start the VM for the changes to take effect. The disk will need to be formatted and mounted before use.

Change placement group

To change a VM's placement group, you must first stop the VM.

Using the CLI:

Stop the VM:

evroc compute vm update myvm --running=false

Change placement group and restart:

evroc compute vm update myvm --placement-group=my-new-pg --running=true

Using the API:

kubectl edit virtualmachine myvm

Update both the running and placementGroup fields:

spec:
  running: false  # stop first
  placementGroup: my-new-pg

After applying, start the VM by setting running: true.

Delete a VM

Delete a VM permanently. This operation cannot be undone.

Warning: Deleting a VM does not delete attached disks or Public IPs. These resources must be deleted separately if no longer needed.

Using the CLI:

evroc compute vm delete myvm

Using the API:

kubectl delete virtualmachine myvm

Next steps