Skip to content

Commit ec471d7

Browse files
authored
Merge pull request #46883 from apinnick/CNV17881-create-vm-cli
CNV-17881: Update "Creating VM from CLI" procedure
2 parents b46c38e + 75eb15c commit ec471d7

File tree

3 files changed

+112
-63
lines changed

3 files changed

+112
-63
lines changed

modules/virt-creating-vm-cli.adoc

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * virt/virtual_machines/virt-create-vms.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="virt-creating-vm-cli_{context}"]
7+
= Using the CLI to create a virtual machine
8+
9+
You can create a virtual machine from a `virtualMachine` manifest.
10+
11+
.Procedure
12+
13+
. Edit the `VirtualMachine` manifest for your VM. For example, the following manifest configures a {op-system-base-full} VM:
14+
+
15+
.Example manifest for a {op-system-base} VM
16+
[source,yaml]
17+
[%collapsible]
18+
====
19+
----
20+
apiVersion: kubevirt.io/v1
21+
kind: VirtualMachine
22+
metadata:
23+
labels:
24+
app: <vm_name> <1>
25+
name: <vm_name>
26+
spec:
27+
dataVolumeTemplates:
28+
- apiVersion: cdi.kubevirt.io/v1beta1
29+
kind: DataVolume
30+
metadata:
31+
name: <vm_name>
32+
spec:
33+
sourceRef:
34+
kind: DataSource
35+
name: rhel9
36+
namespace: openshift-virtualization-os-images
37+
storage:
38+
resources:
39+
requests:
40+
storage: 30Gi
41+
running: false
42+
template:
43+
metadata:
44+
labels:
45+
kubevirt.io/domain: <vm_name>
46+
spec:
47+
domain:
48+
cpu:
49+
cores: 1
50+
sockets: 2
51+
threads: 1
52+
devices:
53+
disks:
54+
- disk:
55+
bus: virtio
56+
name: rootdisk
57+
- disk:
58+
bus: virtio
59+
name: cloudinitdisk
60+
interfaces:
61+
- masquerade: {}
62+
name: default
63+
rng: {}
64+
features:
65+
smm:
66+
enabled: true
67+
firmware:
68+
bootloader:
69+
efi: {}
70+
resources:
71+
requests:
72+
memory: 8Gi
73+
evictionStrategy: LiveMigrate
74+
networks:
75+
- name: default
76+
pod: {}
77+
volumes:
78+
- dataVolume:
79+
name: <vm_name>
80+
name: rootdisk
81+
- cloudInitNoCloud:
82+
userData: |-
83+
#cloud-config
84+
user: cloud-user
85+
password: '<password>' <2>
86+
chpasswd: { expire: False }
87+
name: cloudinitdisk
88+
----
89+
<1> Specify the name of the virtual machine.
90+
<2> Specify the password for cloud-user.
91+
====
92+
93+
. Create a virtual machine by using the manifest file:
94+
+
95+
[source,terminal]
96+
----
97+
$ oc create -f <vm_manifest_file>.yaml
98+
----
99+
100+
. Optional: Start the virtual machine:
101+
+
102+
[source,terminal]
103+
----
104+
$ virtctl start <vm_name>
105+
----

modules/virt-creating-vm.adoc

Lines changed: 0 additions & 61 deletions
This file was deleted.

virt/virtual_machines/virt-create-vms.adoc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Due to differences in storage behavior, some virtual machine templates are incom
2929
====
3030

3131
include::modules/virt-creating-vm-quick-start-web.adoc[leveloffset=+1]
32+
3233
include::modules/virt-creating-vm-wizard-web.adoc[leveloffset=+1]
3334

3435
Refer to the virtual machine wizard fields section when running the web console wizard.
@@ -39,17 +40,21 @@ include::modules/virt-vm-wizard-fields-web.adoc[leveloffset=+2]
3940
Enable the xref:../../scalability_and_performance/using-cpu-manager.adoc#using-cpu-manager[CPU Manager] to use the high-performance workload profile.
4041

4142
include::modules/virt-networking-wizard-fields-web.adoc[leveloffset=+2]
43+
4244
include::modules/virt-storage-wizard-fields-web.adoc[leveloffset=+2]
45+
4346
include::modules/virt-cloud-init-fields-web.adoc[leveloffset=+2]
4447

4548
To configure storage class defaults, use storage profiles. For more information, see xref:../../virt/virtual_machines/virtual_disks/virt-creating-data-volumes.adoc#virt-customizing-storage-profile_virt-creating-data-volumes[Customizing the storage profile].
4649

47-
include::modules/virt-creating-vm-yaml-web.adoc[leveloffset=+1]
48-
include::modules/virt-creating-vm.adoc[leveloffset=+1]
50+
include::modules/virt-creating-vm-yaml-web.adoc[leveloffset=+2]
51+
52+
include::modules/virt-creating-vm-cli.adoc[leveloffset=+1]
4953

5054
:virtualmachine!:
5155

5256
include::modules/virt-vm-storage-volume-types.adoc[leveloffset=+1]
57+
5358
include::modules/virt-about-runstrategies-vms.adoc[leveloffset=+1]
5459

5560
[id="additional-resources_virt-create-vms_{context}"]

0 commit comments

Comments
 (0)