Skip to content

Deploy a VM

This page reviews the different components, workflows, and decisions related to deploying a VM with VM Operator:

The VirtualMachine API

apiVersion: # (1)
kind: VirtualMachine # (2)
  name:      my-vm # (3)
  namespace: my-namespace # (4)
  className:    my-vm-class # (5)
  imageName:    vmi-0a0044d7c690bcbea # (6)
  storageClass: my-storage-class # (7)
  bootstrap: # (8)
      cloudConfig: {}
  1. 👋 The field apiVersion indicates the resource's schema, ex., and version, ex.v1alpha2.

  2. 👋 The field kind specifies the kind of resource, ex. VirtualMachine.

  3. 👋 The field is used to uniquely identify an instance of an API resource in a given Kubernetes namespace.

  4. 👋 The field metadata.namespace denotes in which Kubernetes namespace the API resource is located.

  5. 👋 The field spec.className refers to the name of the VirtualMachineClass resource that provides the hardware configuration when deploying a VM.

    The VirtualMachineClass API is cluster-scoped, and the following command may be used to print all of the VM classes on a cluster:

    kubectl get vmclass

    However, access to these resources is per-namespace. To determine the names of the VM classes that may be used in a given namespace, use the following command:

    kubectl get -n <NAMESPACE> vmclassbinding
  6. 👋 The field spec.imageName refers to the name of the ClusterVirtualMachineImage or VirtualMachineImage resource that provides the disk(s) when deploying a VM.

    • If there is a ClusterVirtualMachineImage resource with the specified name, the cluster-scoped resource is used, otherwise...
    • If there is a VirtualMachineImage resource in the same namespace as the VM being deployed, the namespace-scoped resource is used.

    The following command may be used to print a list of the images available to the entire cluster:

    kubectl get clustervmimage

    Whereas this command may be used to print a list of images available to a given namespace:

    kubectl get -n <NAMESPACE> vmimage
  7. 👋 The field spec.storageClass refers to the Kubernetes storage class used to configure the storage for the VM.

    The following command may be used to print a list of the storage classes available to the entire cluster:

    kubectl get storageclass
  8. 👋 The field spec.bootstrap, and the fields inside of it, are used to configure the VM's bootstrap provider.

Bootstrap Provider

There are a number of methods that may be used to bootstrap a virtual machine's (VM) guest operating system:

Provider Network Config Linux Windows Description
Cloud-Init Cloud-Init Network v2 The industry standard, multi-distro method for cross-platform, cloud instance initialization with modern, VM images
Sysprep Guest OS Customization (GOSC) Microsoft Sysprep is used by VMware to customize Windows images on first-boot
vAppConfig Bespoke For images with bespoke, bootstrap engines driven by vAppConfig properties

Please refer to the documentation for bootstrap providers for more information.