1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-06 06:46:26 +01:00

CNV-17881: Update creating VM from CLI procedure

This commit is contained in:
Avital Pinnick
2022-06-21 17:50:01 +03:00
committed by openshift-cherrypick-robot
parent 61a9c01db0
commit d9ffdadfec
3 changed files with 112 additions and 63 deletions

View File

@@ -0,0 +1,105 @@
// Module included in the following assemblies:
//
// * virt/virtual_machines/virt-create-vms.adoc
:_content-type: PROCEDURE
[id="virt-creating-vm-cli_{context}"]
= Using the CLI to create a virtual machine
You can create a virtual machine from a `virtualMachine` manifest.
.Procedure
. Edit the `VirtualMachine` manifest for your VM. For example, the following manifest 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
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>' <2>
chpasswd: { expire: False }
name: cloudinitdisk
----
<1> Specify the name of the virtual machine.
<2> 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>
----

View File

@@ -1,61 +0,0 @@
// Module included in the following assemblies:
//
// * virt/virtual_machines/virt-create-vms.adoc
:_content-type: PROCEDURE
[id="virt-creating-vm_{context}"]
= Using the CLI to create a virtual machine
.Procedure
The `spec` object of the virtual machine configuration file references
the virtual machine settings, such as the number of cores and the amount
of memory, the disk type, and the volumes to use.
. Attach the virtual machine disk to the virtual machine by referencing
the relevant PVC `claimName` as a volume.
. To create a virtual machine with the {product-title} client, run this command:
+
[source,terminal]
----
$ oc create -f <vm.yaml>
----
. Since virtual machines are created in a *Stopped* state, run a virtual machine
instance by starting it.
[NOTE]
====
A https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/[ReplicaSet]'s purpose is often used to guarantee the availability of a specified number of identical pods.
ReplicaSet is not currently supported in {VirtProductName}.
====
[caption=]
.Domain settings
|===
|Setting | Description
|Cores
|The number of cores inside the virtual machine. Must be a value greater than or equal to 1.
|Memory
|The amount of RAM that is allocated to the virtual machine by the node. Specify a value in *M* for Megabyte or *Gi* for Gigabyte.
|Disks
|The name of the volume that is referenced. Must match the name of a volume.
|===
[caption=]
.Volume settings
|===
|Setting | Description
|Name
|The name of the volume, which must be a DNS label and unique within the virtual machine.
|PersistentVolumeClaim
|The PVC to attach to the virtual machine. The `claimName` of the PVC must be in the same project as the virtual machine.
|===

View File

@@ -29,6 +29,7 @@ Due to differences in storage behavior, some virtual machine templates are incom
====
include::modules/virt-creating-vm-quick-start-web.adoc[leveloffset=+1]
include::modules/virt-creating-vm-wizard-web.adoc[leveloffset=+1]
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]
Enable the xref:../../scalability_and_performance/using-cpu-manager.adoc#using-cpu-manager[CPU Manager] to use the high-performance workload profile.
include::modules/virt-networking-wizard-fields-web.adoc[leveloffset=+2]
include::modules/virt-storage-wizard-fields-web.adoc[leveloffset=+2]
include::modules/virt-cloud-init-fields-web.adoc[leveloffset=+2]
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].
include::modules/virt-creating-vm-yaml-web.adoc[leveloffset=+1]
include::modules/virt-creating-vm.adoc[leveloffset=+1]
include::modules/virt-creating-vm-yaml-web.adoc[leveloffset=+2]
include::modules/virt-creating-vm-cli.adoc[leveloffset=+1]
:virtualmachine!:
include::modules/virt-vm-storage-volume-types.adoc[leveloffset=+1]
include::modules/virt-about-runstrategies-vms.adoc[leveloffset=+1]
[id="additional-resources_virt-create-vms_{context}"]