1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/virt-creating-vm-cli.adoc
2025-02-19 17:05:47 +00:00

69 lines
1.8 KiB
Plaintext

// Module included in the following assemblies:
//
// * virt/virtual_machines/creating_vms_rh/virt-creating-vms-from-cli.adoc
:_mod-docs-content-type: PROCEDURE
[id="virt-creating-vm-cli_{context}"]
= Creating a VM from a VirtualMachine manifest
You can create a virtual machine (VM) from a `VirtualMachine` manifest.
.Procedure
. Edit the `VirtualMachine` manifest for your VM. The following example configures a {op-system-base-full} VM:
+
[NOTE]
====
This example manifest does not configure VM authentication.
====
+
.Example manifest for a {op-system-base} VM
[source,yaml]
----
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: rhel-9-minimal
spec:
dataVolumeTemplates:
- metadata:
name: rhel-9-minimal-volume
spec:
sourceRef:
kind: DataSource
name: rhel9 <1>
namespace: openshift-virtualization-os-images <2>
storage: {}
instancetype:
name: u1.medium <3>
preference:
name: rhel.9 <4>
runStrategy: Always
template:
spec:
domain:
devices: {}
volumes:
- dataVolume:
name: rhel-9-minimal-volume
name: rootdisk
----
<1> The `rhel9` golden image is used to install {op-system-base} 9 as the guest operating system.
<2> Golden images are stored in the `openshift-virtualization-os-images` namespace.
<3> The `u1.medium` instance type requests 1 vCPU and 4Gi memory for the VM. These resource values cannot be overridden within the VM.
<4> The `rhel.9` preference specifies additional attributes that support the {op-system-base} 9 guest operating system.
. Create a virtual machine by using the manifest file:
+
[source,terminal]
----
$ oc create -f <vm_manifest_file>.yaml
----
. Optional: Start the virtual machine:
+
[source,terminal]
----
$ virtctl start <vm_name> -n <namespace>
----