Create a Virtual Machine

This guide shows you how to create a virtual machine using either the CLI or the Kubernetes API.

Prerequisites

Before creating a VM, you need:

  • A boot disk with an operating system image
  • At least one SSH public key (for access to the VM)
  • (Optional) Additional data disks for storage
  • (Optional) A Public IP for inbound internet access
  • (Optional) Security groups for custom firewall rules
  • (Optional) A placement group for high availability

Choose a resource profile

Select a resource profile that matches your workload's CPU, memory, and GPU requirements. Options include:

  • General-purpose (a1a): Balanced CPU and memory
  • Compute-optimized (c1a): Higher CPU-to-memory ratio
  • Memory-optimized (m1a): Higher memory-to-CPU ratio
  • GPU profiles (gn-l40s, gn-b200): For machine learning and HPC workloads

Note: GPU VMs currently support Ubuntu 24.04 only.

Create a VM using the CLI

Create a VM by referencing your boot disk and specifying a resource profile:

evroc compute vm create myvm \
  --running=true \
  --vm-virtual-resources-ref=a1a.s \
  --disk=mybootdisk \
  --boot-from=true \
  --ssh-authorized-key="ssh-ed25519 AAAA..."

CLI parameters

  • --running - Set to true to start the VM immediately (default: true)
  • --vm-virtual-resources-ref - (Required) Resource profile (cannot be changed after creation)
  • --disk - (Required) Reference to a disk (can be specified multiple times)
  • --boot-from - (Required) Whether to boot from this disk (must be specified for each disk)
  • --public-ip - (Optional) Reference to a Public IP
  • --ssh-authorized-key - (Optional) SSH public key (can be specified multiple times)
  • --security-group - (Optional) Security group to add the VM to (can be specified multiple times)
  • --placement-group - (Optional) Placement group for the VM
  • --cloud-init-user-data - (Optional) Cloud-init configuration (base64 or multi-line string)

Example with additional options

Create a VM with multiple disks, a Public IP, and custom security groups:

evroc compute vm create myvm \
  --running=true \
  --vm-virtual-resources-ref=a1a.m \
  --disk=mybootdisk \
  --boot-from=true \
  --disk=mydisk \
  --boot-from=false \
  --public-ip=mypublicip \
  --ssh-authorized-key="ssh-ed25519 AAAA..." \
  --security-group=web-sg \
  --security-group=app-sg

Note: If you don't specify security groups, the VM will be added to the default-sto-1 security group, which blocks all inbound internet traffic. To enable SSH access from the internet, add the default-sto-1-ssh security group using --security-group=default-sto-1-ssh. See Security Groups for more information.

Create a VM using the API

Create a VM by applying a YAML configuration file:

apiVersion: compute.evroclabs.net/v1alpha1
kind: VirtualMachine
metadata:
  name: myvm
spec:
  running: true
  vmVirtualResourcesRef:
    vmVirtualResourcesRefName: a1a.s
  diskRefs:
  - bootFrom: true
    name: mybootdisk
  osSettings:
    ssh:
      authorizedKeys:
      - value: "ssh-ed25519 AAAA..."

Then run:

kubectl apply -f vm.yaml

API specification

  • spec.running - Set to true to start the VM immediately
  • spec.vmVirtualResourcesRef.vmVirtualResourcesRefName - (Required) Resource profile
  • spec.diskRefs - (Required) List of disk references with bootFrom flag
  • spec.osSettings.ssh.authorizedKeys - (Optional) List of SSH public keys
  • spec.osSettings.cloudInitUserData - (Optional) Cloud-init configuration
  • spec.networking.publicIPRef.name - (Optional) Public IP reference
  • spec.networking.securityGroups.securityGroupMemberships - (Optional) Security groups
  • spec.placementGroup - (Optional) Placement group name

Example with additional options

Create a VM with multiple disks, a Public IP, custom security groups, and cloud-init:

apiVersion: compute.evroclabs.net/v1alpha1
kind: VirtualMachine
metadata:
  name: myvm
spec:
  running: true
  vmVirtualResourcesRef:
    vmVirtualResourcesRefName: a1a.m
  placementGroup: my-placement-group
  diskRefs:
  - bootFrom: true
    name: mybootdisk
  - bootFrom: false
    name: mydisk
  osSettings:
    cloudInitUserData: |
      #cloud-config
      packages:
        - nginx
    ssh:
      authorizedKeys:
      - value: "ssh-ed25519 AAAA..."
  networking:
    publicIPv4Address:
      static:
        publicIPRef: mypublicip
    securityGroups:
      securityGroupMemberships:
        - name: web-sg
        - name: app-sg

Verify the VM

Check that the VM was created and is running:

Using the CLI:

evroc compute vm list

Or:

evroc compute vm show myvm

Using the API:

kubectl get virtualmachines

Or:

kubectl get virtualmachine myvm -o yaml

The VM is ready when the Ready status is True and VirtualMachineStatus is Running.

Next steps