Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 10. Using the CLI tools
The two primary CLI tools used for managing resources in the cluster are:
-
The OpenShift Virtualization client
virtctl -
The OpenShift Container Platform client
oc
10.1. Prerequisites Link kopierenLink in die Zwischenablage kopiert!
-
You must install the
virtctlclient.
10.2. OpenShift Container Platform client commands Link kopierenLink in die Zwischenablage kopiert!
The OpenShift Container Platform
oc
VirtualMachine
vm
VirtualMachineInstance
vmi
You can use the
-n <namespace>
| Command | Description |
|---|---|
|
| Log in to the OpenShift Container Platform cluster as
|
|
| Display a list of objects for the specified object type in the current project. |
|
| Display details of the specific resource in the current project. |
|
| Create a resource in the current project from a file name or from stdin. |
|
| Edit a resource in the current project. |
|
| Delete a resource in the current project. |
For more comprehensive information on
oc
10.3. Virtctl commands Link kopierenLink in die Zwischenablage kopiert!
The
virtctl
| Command | Description |
|---|---|
|
| View the
|
|
| View a list of
|
|
| View a list of options for a specific command. |
|
| View a list of global command options for any
|
10.3.1. VM and VMI management commands Link kopierenLink in die Zwischenablage kopiert!
You can use
virtctl
| Command | Description |
|---|---|
|
| Start a VM. |
|
| Start a VM in a paused state. This option enables you to interrupt the boot process from the VNC console. |
|
| Stop a VM. |
|
| Force stop a VM. This option might cause data inconsistency or data loss. |
|
| Pause a VM or VMI. The machine state is kept in memory. |
|
| Unpause a VM or VMI. |
|
| Migrate a VM. |
|
| Restart a VM. |
10.3.2. VM and VMI connection commands Link kopierenLink in die Zwischenablage kopiert!
You can use
virtctl
| Command | Description |
|---|---|
|
| Connect to the serial console of a VMI. |
|
| Create a service that forwards a designated port of a VM or VMI and expose the service on the specified port of the node. |
|
| Open a Virtual Network Client (VNC) connection to a VMI. Accessing the graphical console of a VMI through VNC requires a remote viewer on your local machine. |
|
| Display the port number and connect manually to a VMI by using any viewer through the VNC connection. |
|
| Specify a port number to run the proxy on the specified port, if that port is available. If a port number is not specified, the proxy runs on a random port. |
10.3.3. VM volume export commands Link kopierenLink in die Zwischenablage kopiert!
You can use
virtctl vmexport
| Command | Description |
|---|---|
|
| Create a
|
|
| Delete a
|
|
| Download the volume defined in a
Optional:
|
|
| Create a
|
10.3.4. VM memory dump commands Link kopierenLink in die Zwischenablage kopiert!
You can use the
virtctl memory-dump
--create-claim
Prerequisites
-
The PVC volume mode must be .
FileSystem The PVC must be large enough to contain the memory dump.
The formula for calculating the PVC size is
, where(VMMemorySize + 100Mi) * FileSystemOverheadis the memory dump overhead.100MiYou must enable the hot plug feature gate in the
custom resource by running the following command:HyperConverged$ oc patch hco kubevirt-hyperconverged -n openshift-cnv \ --type json -p '[{"op": "add", "path": "/spec/featureGates", \ "value": "HotplugVolumes"}]'
Downloading the memory dump
You must use the
virtctl vmexport download
$ virtctl vmexport download <vmexport_name> --vm\|pvc=<object_name> \
--volume=<volume_name> --output=<output_file>
| Command | Description |
|---|---|
|
| Save the memory dump of a VM on a PVC. The memory dump status is displayed in the
Optional:
|
|
| Rerun the
This command overwrites the previous memory dump. |
|
| Remove a memory dump. You must remove a memory dump manually if you want to change the target PVC. This command removes the association between the VM and the PVC, so that the memory dump is not displayed in the
|
10.3.5. Image upload commands Link kopierenLink in die Zwischenablage kopiert!
You can use the
virtctl image-upload
| Command | Description |
|---|---|
|
| Upload a VM image to a data volume that already exists. |
|
| Upload a VM image to a new data volume of a specified requested size. |
10.3.6. Environment information commands Link kopierenLink in die Zwischenablage kopiert!
You can use
virtctl
| Command | Description |
|---|---|
|
| View the file systems available on a guest machine. |
|
| View information about the operating systems on a guest machine. |
|
| View the logged-in users on a guest machine. |
10.4. Creating a container using virtctl guestfs Link kopierenLink in die Zwischenablage kopiert!
You can use the
virtctl guestfs
libguestfs-tools
Procedure
To deploy a container with
, mount the PVC, and attach a shell to it, run the following command:libguestfs-tools$ virtctl guestfs -n <namespace> <pvc_name>ImportantThe
argument is required. If you do not include it, an error message appears.<pvc_name>
10.5. Libguestfs tools and virtctl guestfs Link kopierenLink in die Zwischenablage kopiert!
Libguestfs
libguestfs
You can also use the
virtctl guestfs
virt-
| Command | Description |
|---|---|
|
| Edit a file interactively in your terminal. |
|
| Inject an ssh key into the guest and create a login. |
|
| See how much disk space is used by a VM. |
|
| See the full list of all RPMs installed on a guest by creating an output file containing the full list. |
|
| Display the output file list of all RPMs created using the
|
|
| Seal a virtual machine disk image to be used as a template. |
By default,
virtctl guestfs
| Flag Option | Description |
|---|---|
|
| Provides help for
|
|
| To use a PVC from a specific namespace. If you do not use the
If you do not include a
|
|
| Lists the
You can configure the container to use a custom image by using the
|
|
| Indicates that
By default,
If a cluster does not have any
If not set, the
|
|
| Shows the pull policy for the
You can also overwrite the image’s pull policy by setting the
|
The command also checks if a PVC is in use by another pod, in which case an error message appears. However, once the
libguestfs-tools
virtctl guestfs
The
virtctl guestfs