mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
97 lines
2.4 KiB
Plaintext
97 lines
2.4 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * virt/creating_vms_advanced/creating_vms_cli/virt-creating-vms-from-container-disks.adoc
|
|
|
|
:_mod-docs-content-type: PROCEDURE
|
|
[id="virt-creating-vm-import-cli_{context}"]
|
|
= Creating a VM from a container disk by using the CLI
|
|
|
|
You can create a virtual machine (VM) from a container disk by using the command line.
|
|
|
|
.Prerequisites
|
|
|
|
* You must have access credentials for the container registry that contains the container disk.
|
|
* 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 from a container disk, run the following command:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ virtctl create vm --name vm-rhel-9 --instancetype u1.small --preference rhel.9 --volume-containerdisk src:registry.redhat.io/rhel9/rhel-guest-image:9.5
|
|
----
|
|
|
|
. Review the `VirtualMachine` manifest for your VM:
|
|
+
|
|
[source,yaml]
|
|
----
|
|
apiVersion: kubevirt.io/v1
|
|
kind: VirtualMachine
|
|
metadata:
|
|
name: vm-rhel-9 # <1>
|
|
spec:
|
|
instancetype:
|
|
name: u1.small # <2>
|
|
preference:
|
|
name: rhel.9 # <3>
|
|
runStrategy: Always
|
|
template:
|
|
metadata:
|
|
creationTimestamp: null
|
|
spec:
|
|
domain:
|
|
devices: {}
|
|
resources: {}
|
|
terminationGracePeriodSeconds: 180
|
|
volumes:
|
|
- containerDisk:
|
|
image: registry.redhat.io/rhel9/rhel-guest-image:9.5 # <4>
|
|
name: vm-rhel-9-containerdisk-0
|
|
----
|
|
<1> The VM name.
|
|
<2> The instance type to use to control resource sizing of the VM.
|
|
<3> The preference to use.
|
|
<4> The URL of the container disk.
|
|
|
|
. Create the VM by running the following command:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ oc create -f <vm_manifest_file>.yaml
|
|
----
|
|
|
|
.Verification
|
|
|
|
. Monitor the status of the VM:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ oc get vm <vm_name>
|
|
----
|
|
+
|
|
If the provisioning is successful, the VM status is `Running`:
|
|
+
|
|
.Example output
|
|
[source,terminal]
|
|
----
|
|
NAME AGE STATUS READY
|
|
vm-rhel-9 18s Running True
|
|
----
|
|
|
|
. Verify that provisioning is complete and that the VM has started by accessing its serial console:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ virtctl console <vm_name>
|
|
----
|
|
+
|
|
If the VM is running and the serial console is accessible, the output looks as follows:
|
|
+
|
|
.Example output
|
|
[source,terminal]
|
|
----
|
|
Successfully connected to vm-rhel-9 console. The escape sequence is ^]
|
|
----
|