Create VMs

Virtual Machines

Once you've enabled KubeVirt in your Kubernetes cluster, let's begin creating your first VM. We begin by navigating to the Virtual Machines section in the console by selecting KubeVirt from the App Switcher.

Next, click the + Add Virtual Machine button in the top-right corner of the screen, as shown above.

Configure VM

In the next step, we have two options; we can create the VM using a YAML file, or use the new Create a New VM Instance wizard.

  • YAML file - Users can now use a YAML file to define the predetermined VM configuration settings included in the file. This makes for more reliable replication, better readability and increased reliability.
  • Using the VM Instance wizard - With this option, you have the flexibility to input all the info specific to your needs using our UI.

Create VM using YAML File

After clicking on the + Add Virtual Machine button in the upper-right corner, the Basic Settings window opens to the default view.

Next, click on the Create Using YAML button in the top-right corner. This opens a new view where you can select the Cluster and Namespace to deploy the VM to. Now, enter, edit, or upload the YAML file value details in the open field. In this setup, we use a kubevirt.io default YAML file for demonstration purposes.

Be sure to set the "VM Type" field to the correct value (i.e. VirtualMachine or VirtualMachineInstance), based on the resource type specified in your YAML.

Below is a copy of the default YAML file we used. This can be utilized for testing in this environment. This example uses a fedora cloud image with cloud-init. To understand the details and more advanced options, refer to this section of the official KubeVirt User Guide. Add this sample Fedora VirtualMachine YAML into the VM creation wizard box.

YAML
Copy

Your YAML file must be syntactically correct, or it will throw an error message stating: Provided YAML code is invalid.

Finally, click on the Create VM button to start the creation process. The VM create task will be scheduled, and once completed, you will see it in the VM table view.

Create a New VM Instance Wizard

The new method clients can use is the new Create a New VM Instance wizard.

Step 1. Basic Settings

We begin by naming our VM. In this instance. Next, choose whether you will be creating a single or multiple VMs. If multiple, click the Create multiple VMs check box. Next, select the cluster and namespace the instance will be connected to, as well as the Run Strategy. There are four run strategies to choose from:

  • Always - In this state, an instance will always exist. If it crashes, a new one will be created.
  • RerunOnFailure - Here, an instance will be respawned if the former instance fails out in an error state. It will not be re-created unless it was shut down from inside the guest.
  • Manual - The existence of an instance is limited exclusively to a start/stop/restart value in the VM subresource endpoint
  • Halted - No instance will exist. If a guest is already running, it will be stopped.

For this tutorial, we have chosen Manual.

Step 2. Storage Selection

Here, users define the specific storage type and other details. The options for Virtual Instances are:

  • ReadWriteMany or ReadWriteOnce
  • The size in GiB
  • Storage Class

User also have the option to Clone an Existing PVC or Attach an Existing Disk.

The Options for Virtual Machines are:

  • ReadWriteMany or ReadWriteOnce
  • The size in GiB
  • Storage Class

Admins have the option from selecting from:

  • Import an Image from HTTP URL
  • Import an Image from Registry URL
  • Upload an Image from Disk
  • Clone existing PVC
  • Attach Existing Disk

Step 3. Preset Selections

In this step, users select one of two options; either a preset value or manually define values for the number of VCPUs and amount of RAM.

Step 4 Network Selection

You have two options when selecting the Binding Mode for Pod Network:

  • Masquerade - In this mode, KubeVirt allocates internally NAT'd IP addresses to the image
  • Bridge - Here, virtual machines are linked to the network backend via a linux "bridge"

Live migration is not allowed with a pod network binding of bridge interface type

Step 5. Configure Instance Details

Kubevirt utilizes cloud-init as a sort of template, similar to a kubevirt VM or VMI yaml config. These can be a useful tool, especially when debugging test cases. Here, users can either enter a cloud-init script or upload a cloud-init file. More examples of cloud-init configurations can be found at https://cloudinit.readthedocs.io/.

Step 6. Advanced Options

In this section, further details can be added via a YAML file. Below, we appended an additional dataVolume.

Step 7. Review and Create

In the final step, we analyze our choices to ensure they are correct. If a value needs to be corrected, we can still go back using the Back button to modify a selection. After editing is complete, click the Next button to again move forward in the process. All the info previously supplied should remain resident.

If satisfied with the settings, click the Create button to generate the new instance.

Should you have thoughts, questions or issues with this process, please do not hesitate to reach out to our support team for more information.

Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard