Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 3. Getting started
3.1. Getting started with OpenShift Virtualization Link kopierenLink in die Zwischenablage kopiert!
Explore OpenShift Virtualization by taking guided tours, installing the Operator, and configuring a basic environment. Learn how to migrate from your current platform, then learn more about how to deploy and manage virtual machines (VMs) by following the additional resources links.
Cluster configuration procedures require cluster-admin privileges.
3.1.1. Take the Getting started tour Link kopierenLink in die Zwischenablage kopiert!
The Getting started tour introduces several key aspects of using OpenShift Virtualization. There are two ways to start the tour.
Prerequisites
- You have access to the OpenShift Container Platform web console.
Procedure
- If you see the Welcome to OpenShift Virtualization dialog, click Start Tour.
-
Otherwise, go to Virtualization
Overview Settings User Getting started resources Guided tour.
3.1.2. Take a quick start tour Link kopierenLink in die Zwischenablage kopiert!
You can explore several OpenShift Virtualization capabilities by taking quick start tours in the web console.
Prerequisites
- You have access to the OpenShift Container Platform web console.
Procedure
- Click the Help icon ? in the menu bar on the header of the OpenShift Container Platform web console.
-
Select Quick Starts. You can filter the list of tours by entering the keyword
virtualin the Filter field.
3.2. Using the CLI tools Link kopierenLink in die Zwischenablage kopiert!
You can manage OpenShift Virtualization resources by using the virtctl command-line tool. Virtual machine (VM) commands can also be used to manage virtual machine instances (VMIs) unless otherwise specified.
You can access and change VM disk images by using the libguestfs command-line tool. You deploy libguestfs by using the virtctl libguestfs command.
3.2.1. Install the virtctl binary Link kopierenLink in die Zwischenablage kopiert!
Download and install the virtctl binary that is available from the OpenShift Container Platform web console. You can run virtctl on Red Hat Enterprise Linux (RHEL) 9 or later, other Linux operating systems, Windows, or macOS.
Procedure
-
Navigate to the Virtualization
Overview page in the web console. -
Click the Download virtctl link to download the
virtctlbinary for your operating system. Install
virtctl:For RHEL and other Linux operating systems:
Decompress the archive file:
$ tar -xvf <virtctl-version-distribution.arch>.tar.gzRun the following command to make the
virtctlbinary executable:$ chmod +x <path/virtctl-file-name>Move the
virtctlbinary to a directory in yourPATHenvironment variable.You can check your path by running the following command:
$ echo $PATHSet the
KUBECONFIGenvironment variable:$ export KUBECONFIG=/home/<user>/clusters/current/auth/kubeconfig
For Windows:
- Decompress the archive file.
-
Navigate the extracted folder hierarchy and double-click the
virtctlexecutable file to install the client. Move the
virtctlbinary to a directory in yourPATHenvironment variable.You can check your path by running the following command:
C:\> path
For macOS:
- Decompress the archive file.
Move the
virtctlbinary to a directory in yourPATHenvironment variable.You can check your path by running the following command:
echo $PATH
3.2.2. virtctl information commands Link kopierenLink in die Zwischenablage kopiert!
You can use the following virtctl commands to view the client and server versions and to list the commands and options that are available.
| 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 |
3.2.3. VM information commands Link kopierenLink in die Zwischenablage kopiert!
You can use the following virtctl commands to view the file systems, operating systems, and logged-in users of a guest machine.
| 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. |
3.2.4. VM manifest creation commands Link kopierenLink in die Zwischenablage kopiert!
You can use the following virtctl create commands to create manifests for virtual machines (VMs), instance types, and preferences.
| Command | Description |
|---|---|
|
|
Create a |
|
| Create a VM manifest, specifying a name for the VM. |
|
| Create a VM manifest with a cloud-init configuration to create the selected user and either add an SSH public key from the supplied string, or a password from a file. |
|
| Create a VM manifest with a user and password combination injected from the selected secret. |
|
| Create a VM manifest with an SSH public key injected from the selected secret. |
|
|
Create a VM manifest, specifying a config map to use as the sysprep volume. The config map must contain a valid answer file named |
|
| Create a VM manifest that uses an existing cluster-wide instance type. |
|
| Create a VM manifest that uses an existing namespaced instance type. |
|
| Create a manifest for a cluster-wide instance type. |
|
| Create a manifest for a namespaced instance type. |
|
| Create a manifest for a cluster-wide VM preference, specifying a name for the preference. |
|
| Create a manifest for a namespaced VM preference. |
3.2.5. VM management commands Link kopierenLink in die Zwischenablage kopiert!
You can use the following virtctl commands to start, stop, pause, restart, and migrate virtual machines (VMs).
| 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. The machine state is kept in memory. |
|
| Unpause a VM. |
|
| Migrate a VM. |
|
| Cancel a VM migration. |
|
| Restart a VM. |
3.2.6. VM connection commands Link kopierenLink in die Zwischenablage kopiert!
You can use the following virtctl commands to connect to the console of a virtual machine (VM), open an SSH connection, copy files, and expose a port as a service.
| Command | Description |
|---|---|
|
| Connect to the serial console of a VM. |
|
| Create a service that forwards a designated port of a VM and expose the service on the specified port of the node.
Example: |
|
| Copy a file from your machine to a VM. This command uses the private key of an SSH key pair. The VM must be configured with the public key. |
|
| Copy a file from a VM to your machine. This command uses the private key of an SSH key pair. The VM must be configured with the public key. |
|
| Open an SSH connection with a VM. This command uses the private key of an SSH key pair. The VM must be configured with the public key. |
|
| Connect to the VNC console of a VM.
You must have |
|
| Display the port number and connect manually to a VM 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. |
3.2.7. VM export commands Link kopierenLink in die Zwischenablage kopiert!
You can use the following virtctl vmexport commands to export a volume from a virtual machine (VM), a VM snapshot, or a persistent volume claim (PVC). These commands create the export, download the volume, and retrieve the manifest.
| Command | Description |
|---|---|
|
|
Create a
|
|
|
Delete a |
|
|
Download the volume defined in a
Optional:
|
|
|
Create a |
|
| Retrieve the manifest for an existing export. The manifest does not include the header secret. |
|
| Create a VM export for a VM example, and retrieve the manifest. The manifest does not include the header secret. |
|
| Create a VM export for a VM snapshot example, and retrieve the manifest. The manifest does not include the header secret. |
|
| Retrieve the manifest for an existing export. The manifest includes the header secret. |
|
| Retrieve the manifest for an existing export in json format. The manifest does not include the header secret. |
|
| Retrieve the manifest for an existing export. The manifest includes the header secret and writes it to the file specified. |
3.2.8. Hot plug and hot unplug commands Link kopierenLink in die Zwischenablage kopiert!
You can use the following virtctl commands to add or remove a virtual disk while a virtual machine (VM) or virtual machine instance (VMI) is running.
| Command | Description |
|---|---|
|
| Hot plug a data volume or persistent volume claim (PVC). Optional:
|
|
| Hot unplug a virtual disk. |
3.2.9. Image upload commands Link kopierenLink in die Zwischenablage kopiert!
You can use the following virtctl image-upload commands to upload a virtual machine (VM) image to a new or existing data volume.
| 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. |
|
|
Upload a VM image to a new data volume and create an associated |
3.2.10. Deploy libguestfs by using virtctl Link kopierenLink in die Zwischenablage kopiert!
You can use the virtctl guestfs command to deploy an interactive container that has libguestfs-tools installed and a persistent volume claim (PVC) attached. Use the container to inspect and modify the VM disk on the PVC.
Procedure
To deploy a container with
libguestfs-tools, mount the PVC, and attach a shell to it, run the following command:$ virtctl guestfs -n <namespace> <pvc_name>ImportantThe
<pvc_name>argument is required. If you do not include it, an error message appears.
3.2.11. Libguestfs and virtctl guestfs commands Link kopierenLink in die Zwischenablage kopiert!
The libguestfs tools let you access and modify virtual machine (VM) disk images. You can run them in the container that virtctl guestfs deploys to view and edit files in a guest, clone VMs, and resize disks.
You can also use the virtctl guestfs command and its sub-commands to modify, inspect, and debug VM disks on a PVC. To see a complete list of possible sub-commands, enter virt- on the command line and press the Tab key. For example:
| 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 creates a session with everything needed to manage a VM disk. However, the command also supports several flag options if you want to customize the behavior:
| 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 process starts, the setup cannot avoid a new pod using the same PVC. You must verify that there are no active virtctl guestfs pods before starting the VM that accesses the same PVC.
The virtctl guestfs command accepts only a single PVC attached to the interactive pod.