mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
95 lines
2.9 KiB
Plaintext
95 lines
2.9 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * virt/creating_vms_advanced/creating_vms_cli/virt-creating-vms-from-cli.adoc
|
|
|
|
:_mod-docs-content-type: PROCEDURE
|
|
[id="virt-creating-vm-cli_{context}"]
|
|
= Creating a VM from a VirtualMachine manifest
|
|
|
|
[role="_abstract"]
|
|
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 have installed the `virtctl` CLI.
|
|
* You have installed the {oc-first}.
|
|
|
|
.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-import type:ds,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
|
|
spec:
|
|
dataVolumeTemplates:
|
|
- metadata:
|
|
name: imported-volume-mk4lj
|
|
spec:
|
|
sourceRef:
|
|
kind: DataSource
|
|
name: rhel9
|
|
namespace: openshift-virtualization-os-images
|
|
storage:
|
|
resources: {}
|
|
instancetype:
|
|
inferFromVolume: imported-volume-mk4lj
|
|
inferFromVolumeFailurePolicy: Ignore
|
|
preference:
|
|
inferFromVolume: imported-volume-mk4lj
|
|
inferFromVolumeFailurePolicy: Ignore
|
|
runStrategy: Always
|
|
template:
|
|
spec:
|
|
domain:
|
|
devices:
|
|
video:
|
|
type: virtio
|
|
memory:
|
|
guest: 512Mi
|
|
resources: {}
|
|
terminationGracePeriodSeconds: 180
|
|
volumes:
|
|
- dataVolume:
|
|
name: imported-volume-mk4lj
|
|
name: imported-volume-mk4lj
|
|
----
|
|
+
|
|
|
|
* `name: rhel-9-minimal` specifies the name of the VM.
|
|
* `name: rhel9` specifies the boot source for the guest operating system in the `sourceRef` section.
|
|
* `namespace: openshift-virtualization-os-images` specifies the namespace for the boot source. Golden images are stored in the `openshift-virtualization-os-images` namespace.
|
|
* `instancetype: inferFromVolume: imported-volume-mk4lj` specifies the instance type inferred from the selected `DataSource` object.
|
|
* `preference: inferFromVolume: imported-volume-mk4lj` specifies that the preference is inferred from the selected `DataSource` object.
|
|
* `type: virtio` specifies the use of a custom video device (a VirtIO device in this example) to enable hardware graphics acceleration. Enabling a custom video device is in Technology Preview for {VirtProductName} 4.21.
|
|
|
|
. 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>
|
|
----
|