mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
88 lines
2.3 KiB
Plaintext
88 lines
2.3 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. To simplify the creation of these manifests, you can use the `virtctl` command-line tool.
|
|
|
|
.Prerequisites
|
|
|
|
* You must have the `virtctl` command-line tool installed.
|
|
|
|
.Procedure
|
|
|
|
. Create a `VirtualMachine` manifest for your VM and save it as a YAML file. For example, to create a minimal {op-system-base-full} VM, run the following command:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ virtctl create vm --name rhel-9-minimal --volume-datasource src:openshift-virtualization-os-images/rhel9
|
|
----
|
|
|
|
. Review the `VirtualMachine` manifest for your 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 # <1>
|
|
spec:
|
|
dataVolumeTemplates:
|
|
- metadata:
|
|
name: imported-volume-mk4lj
|
|
spec:
|
|
sourceRef:
|
|
kind: DataSource
|
|
name: rhel9 # <2>
|
|
namespace: openshift-virtualization-os-images # <3>
|
|
storage:
|
|
resources: {}
|
|
instancetype:
|
|
inferFromVolume: imported-volume-mk4lj # <4>
|
|
inferFromVolumeFailurePolicy: Ignore
|
|
preference:
|
|
inferFromVolume: imported-volume-mk4lj # <5>
|
|
inferFromVolumeFailurePolicy: Ignore
|
|
runStrategy: Always
|
|
template:
|
|
spec:
|
|
domain:
|
|
devices: {}
|
|
memory:
|
|
guest: 512Mi
|
|
resources: {}
|
|
terminationGracePeriodSeconds: 180
|
|
volumes:
|
|
- dataVolume:
|
|
name: imported-volume-mk4lj
|
|
name: imported-volume-mk4lj
|
|
----
|
|
<1> The VM name.
|
|
<2> The boot source for the guest operating system.
|
|
<3> The namespace for the boot source. Golden images are stored in the `openshift-virtualization-os-images` namespace.
|
|
<4> The instance type is inferred from the selected `DataSource` object.
|
|
<5> The preference is inferred from the selected `DataSource` object.
|
|
|
|
. 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>
|
|
----
|