// Module included in the following assemblies:
//
// * virt/creating_vms_advanced/creating_vms_cli/virt-creat-vm-manifest-virtctl.adoc
// * virt/managing_vms/ssh/virt-using-virtctl-ssh.adoc

ifeval::["{context}" == "virt-creating-vms-from-instance-types"]
:virt-create-vms:
:title: Creating a VM
endif::[]
ifeval::["{context}" == "static-key"]
:static-key:
:title: Adding a key when creating a VM
endif::[]
ifeval::["{context}" == "dynamic-key"]
:dynamic-key:
:title: Enabling dynamic key injection when creating a VM
endif::[]

:_mod-docs-content-type: PROCEDURE
[id="virt-creating-vm-instancetype_{context}"]
= Creating a VM from an instance type by using the web console

ifdef::virt-create-vms[]
[role="_abstract"]
You can create a virtual machine (VM) from an instance type by using the {product-title} web console. You can also use the web console to create a VM by copying an existing snapshot or to clone a VM.

You can create a VM from a list of available bootable volumes. You can add Linux- or Windows-based volumes to the list.
endif::[]

ifdef::static-key[]
[role="_abstract"]
You can add a statically managed SSH key when you create a virtual machine (VM) from an instance type by using the {product-title} web console. The key is added to the VM as a cloud-init data source at first boot. This method does not affect cloud-init user data.
endif::[]
ifdef::dynamic-key[]
[role="_abstract"]
You can enable dynamic SSH key injection when you create a virtual machine (VM) from an instance type by using the {product-title} web console. Then, you can add or revoke the key at runtime.

[NOTE]
====
Only {op-system-base-full} 9 supports dynamic key injection.
====

The key is added to the VM by the QEMU guest agent, which is installed with {op-system-base} 9.
endif::[]

.Procedure

. In the web console, navigate to *Virtualization* -> *Catalog*.
+
The *InstanceTypes* tab opens by default.
ifndef::openshift-dedicated[]
+
[NOTE]
====
When configuring a downward-metrics device on an {ibm-z-name} system that uses a VM preference, set the `spec.preference.name` value to `rhel.9.s390x` or another available preference with the format `*.s390x`.
====
endif::openshift-dedicated[]
. Heterogeneous clusters only: To filter the bootable volumes using the options provided, click *Architecture*.

. Select either of the following options:
* Select a suitable bootable volume from the list. If the list is truncated, click the *Show all* button to display the entire list.
+
[NOTE]
====
The bootable volume table lists only those volumes in the `openshift-virtualization-os-images` namespace that have the `instancetype.kubevirt.io/default-preference` label.
====
+
** Optional: Click the star icon to designate a bootable volume as a favorite. Starred bootable volumes appear first in the volume list.

* Click *Add volume* to upload a new volume or to use an existing persistent volume claim (PVC), a volume snapshot, or a `containerDisk` volume. Click *Save*.
+
Logos of operating systems that are not available in the cluster are shown at the bottom of the list. You can add a volume for the required operating system by clicking the *Add volume* link.
+
In addition, there is a link to the *Create a Windows bootable volume* quick start. The same link appears in a popover if you hover the pointer over the question mark icon next to the _Select volume to boot from_ line.
+
Immediately after you install the environment or when the environment is disconnected, the list of volumes to boot from is empty. In that case, three operating system logos are displayed: Windows, {op-system-base}, and Linux. You can add a new volume that meets your requirements by clicking the *Add volume* button.

ifdef::virt-create-vms[]
. Click an instance type tile and select the resource size appropriate for your workload. You can select huge pages for Red{nbsp}Hat-provided instance types of the *M* and *CX* series. Huge page options are identified by names that end with *1gi*.
endif::[]
ifdef::dynamic-key[]
. Click the *Red Hat Enterprise Linux 9 VM* tile.
endif::[]
ifdef::virt-create-vms[]
. Optional: Choose the virtual machine details, including the VM's name, that apply to the volume you are booting from:
endif::[]
ifdef::virt-create-vms[]
** For a Linux-based volume, follow these steps to configure SSH:
endif::[]

.. If you have not already added a public SSH key to your project, click the edit icon beside *Authorized SSH key* in the *VirtualMachine details* section.
.. Select one of the following options:
+
--
* *Use existing*: Select a secret from the secrets list.
* *Add new*: Follow these steps:
... Browse to the public SSH key file or paste the file in the key field.
... Enter the secret name.
... Optional: Select *Automatically apply this key to any new VirtualMachine you create in this project*.
--
.. Click *Save*.

ifdef::virt-create-vms[]
** For a Windows volume, follow either of these set of steps to configure sysprep options:
*** If you have not already added sysprep options for the Windows volume, follow these steps:
... Click the edit icon beside *Sysprep* in the *VirtualMachine details* section.
... Add the *Autoattend.xml* answer file.
... Add the *Unattend.xml* answer file.
... Click *Save*.
*** If you want to use existing sysprep options for the Windows volume, follow these steps:
... Click *Attach existing sysprep*.
... Enter the name of the existing sysprep *Unattend.xml* answer file.
... Click *Save*.
endif::[]
ifdef::dynamic-key[]
. Set *Dynamic SSH key injection* in the *VirtualMachine details* section to on.
endif::[]
. Optional: If you are creating a Windows VM, you can mount a Windows driver disk:
.. Click the *Customize VirtualMachine* button.
.. On the *VirtualMachine details* page, click *Storage*.
.. Select the *Mount Windows drivers disk* checkbox.
. Optional: Click *View YAML & CLI* to view the YAML file. Click *CLI* to view the CLI commands. You can also download or copy either the YAML file contents or the CLI commands.
. Click *Create VirtualMachine*.

.Result

After the VM is created, you can monitor the status on the *VirtualMachine details* page.

ifeval::["{context}" == "virt-creating-vms"]
:!virt-create-vms:
endif::[]
ifeval::["{context}" == "static-key"]
:!static-key:
endif::[]
ifeval::["{context}" == "dynamic-key"]
:!dynamic-key:
endif::[]
