mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 21:46:22 +01:00
107 lines
2.4 KiB
Plaintext
107 lines
2.4 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:
|
|
+
|
|
.Example manifest for a {op-system-base} VM
|
|
[source,yaml]
|
|
[%collapsible]
|
|
====
|
|
----
|
|
apiVersion: kubevirt.io/v1
|
|
kind: VirtualMachine
|
|
metadata:
|
|
labels:
|
|
app: <vm_name> <1>
|
|
name: <vm_name>
|
|
spec:
|
|
dataVolumeTemplates:
|
|
- apiVersion: cdi.kubevirt.io/v1beta1
|
|
kind: DataVolume
|
|
metadata:
|
|
name: <vm_name>
|
|
spec:
|
|
sourceRef:
|
|
kind: DataSource
|
|
name: rhel9 <2>
|
|
namespace: openshift-virtualization-os-images
|
|
storage:
|
|
resources:
|
|
requests:
|
|
storage: 30Gi
|
|
running: false
|
|
template:
|
|
metadata:
|
|
labels:
|
|
kubevirt.io/domain: <vm_name>
|
|
spec:
|
|
domain:
|
|
cpu:
|
|
cores: 1
|
|
sockets: 2
|
|
threads: 1
|
|
devices:
|
|
disks:
|
|
- disk:
|
|
bus: virtio
|
|
name: rootdisk
|
|
- disk:
|
|
bus: virtio
|
|
name: cloudinitdisk
|
|
interfaces:
|
|
- masquerade: {}
|
|
name: default
|
|
rng: {}
|
|
features:
|
|
smm:
|
|
enabled: true
|
|
firmware:
|
|
bootloader:
|
|
efi: {}
|
|
resources:
|
|
requests:
|
|
memory: 8Gi
|
|
evictionStrategy: LiveMigrate
|
|
networks:
|
|
- name: default
|
|
pod: {}
|
|
volumes:
|
|
- dataVolume:
|
|
name: <vm_name>
|
|
name: rootdisk
|
|
- cloudInitNoCloud:
|
|
userData: |-
|
|
#cloud-config
|
|
user: cloud-user
|
|
password: '<password>' <3>
|
|
chpasswd: { expire: False }
|
|
name: cloudinitdisk
|
|
----
|
|
<1> Specify the name of the virtual machine.
|
|
<2> Specify the name in the `spec.dataImportCronTemplate.spec.managedDataSource` field in the `Hyperconvered` CR.
|
|
<3> Specify the password for cloud-user.
|
|
====
|
|
|
|
. 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>
|
|
----
|