1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/mtc-deploying-a-vm.adoc
A.Arnold 8e8721cabe MIG-1620: VM storage migration
Signed-off-by: A.Arnold <anarnold@redhat.com>
2025-04-18 12:24:16 +00:00

112 lines
3.2 KiB
Plaintext

// Module included in the following assemblies:
// * migration_toolkit_for_containers/mtc-migrating-vms.adoc
:_mod-docs-content-type: PROCEDURE
[id="mtc-deploying-a-vm_{context}"]
= Deploying a virtual machine
After installing and activating {VirtProductName} and Containerized Data Importer (CDI), create a namespace and deploy a virtual machine (VM).
.Procedure
* Deploy the YAML, which creates both a VM definition and a data volume containing the Fedora operating system.
+
In the following example, the namespace `mig-vm` is used and the following YAML is used to create a Fedora VM, create and a datavolume containing the Fedora operating system:
+
[source,yaml]
----
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: rhel9-lime-damselfly-72
namespace: mig-vm # <1>
labels:
app: rhel9-lime-damselfly-72
kubevirt.io/dynamic-credentials-support: 'true'
vm.kubevirt.io/template: rhel9-server-small
vm.kubevirt.io/template.namespace: openshift
vm.kubevirt.io/template.revision: '1'
vm.kubevirt.io/template.version: v0.31.1
spec:
dataVolumeTemplates:
- apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
name: rhel9-lime-damselfly-72
spec:
sourceRef:
kind: DataSource
name: rhel9
namespace: openshift-virtualization-os-images
storage:
resources:
requests:
storage: 30Gi
running: true # <2>
template:
metadata:
annotations:
vm.kubevirt.io/flavor: small
vm.kubevirt.io/os: rhel9
vm.kubevirt.io/workload: server
creationTimestamp: null
labels:
kubevirt.io/domain: rhel9-lime-damselfly-72 # <3>
kubevirt.io/size: small
network.kubevirt.io/headlessService: headless
spec:
architecture: amd64
domain:
cpu:
cores: 1
sockets: 1
threads: 1
devices:
disks:
- disk:
bus: virtio
name: rootdisk
- disk:
bus: virtio
name: cloudinitdisk
interfaces:
- masquerade: {}
model: virtio
name: default
rng: {}
features:
acpi: {}
smm:
enabled: true
firmware:
bootloader:
efi: {}
machine:
type: pc-q35-rhel9.4.0
memory:
guest: 2Gi
resources: {}
networks:
- name: default
pod: {}
terminationGracePeriodSeconds: 180
volumes:
- dataVolume:
name: rhel9-lime-damselfly-72
name: rootdisk
- cloudInitNoCloud:
userData: |-
#cloud-config
user: cloud-user
password: password
chpasswd: { expire: False }
name: cloudinitdisk
----
<1> In this example, the namespace `mig-vm` is used.
<2> Use `running: true` to indicate that the VM should be started after creation.
<3> The data volume creates a persistent volume claim (PVC) called `rhel9-lime-damselfly-72`, which is the same name as the data volume.
The persistent volume (PV) is populated with the operating system, and the VM is started.