Bookmark this page

Deploying the OpenShift Virtualization Operator

Objectives

  • Deploy the OpenShift Virtualization operator in an existing Red Hat OpenShift environment.

Preparing an RHOCP Cluster for Virtualization

You can deploy RHOCP clusters in many environments. Adding the virtualization operator to the cluster requires extra specifications. Traditionally, an RHOCP cluster that adds the Red Hat OpenShift Virtualization operator uses on-premise bare metal systems. Cloud providers can now deliver RHOCP infrastructure on cloud-based bare metal servers. IBM Cloud and Amazon Web Services have supported offerings for RHOCP clusters on bare metal instances that are suitable for using the virtualization operator within a cluster.

Note

For more information about deploying RHOCP clusters on IBM Cloud bare metal nodes, refer to the following article: https://access.redhat.com/articles/6738731

Before installation, verify that an RHOCP cluster meets the minimum requirements to support the features of the OpenShift virtualization operator.

  • You must install the cluster by using bare metal infrastructure, either on-premise or through a supported cloud partner, with Red Hat Enterprise Linux CoreOS workers.

  • All CPUs must be supported by Red Hat Enterprise Linux 9, support Intel 64 or AMD64 CPU extensions, have Intel VT or AMD-V hardware virtualization enabled, and have the no-execute (NX) flag enabled.

  • Compute nodes must exceed the requirements of the virtual machines in the cluster.

  • For high availability, either use installer-provisioned infrastructure with machine health checks or manually monitor node availability.

  • For live migration, shared storage is required.

  • You must enable Operator Lifecycle Manager on restricted networks for deployment in a disconnected environment.

Note

Red Hat recommends not exceeding tested maximums to maintain performance. Review the tested maximums for Red Hat OpenShift Virtualization 4.14 in the Supported Limits for OpenShift Virtualization 4.x article at https://access.redhat.com/articles/6571671

Installing the Red Hat OpenShift Virtualization Operator

As with other operators, you can install the Red Hat OpenShift Virtualization operator by using either the web console or the command line. To install the operator by using the web console, navigate to OperatorsOperator Hub in the left panel. Type OpenShift Virtualization in the search bar, and select OpenShift Virtualization.

Configure your preferred channel and version options and click Install to open the Install Operator page. Review or augment the installation options and click Install to deploy the operator to the openshift-cnv namespace.

Figure 1.2: OpenShift Virtualization Operator installation

OpenShift Virtualization requires that the KubeVirt HyperConverged Operator (HCO) is installed in order to create virtual machines. The HCO deploys and manages OpenShift Virtualization and its components. The HCO also creates Custom Resources (CR) to deploy and manage supplemental operators for OpenShift Virtualization. These CRs include the Containerized Data Importer operator, the Scheduling, Scale, and Performance operator, and the Cluster Network Addons operator.

When the OpenShift Virtualization operator installs successfully, the web console displays a prompt to create a HyperConverged instance.

Figure 1.3: Post-installation creation of a hyperconverged instance

Click Create HyperConverged to create a HyperConverged instance in your cluster.

Note

After the first HyperConverged instance creation completes, you must refresh the web console browser page before the virtualization menu items appear. It is occasionally necessary to log out and back in to the web console before seeing the new features.

OpenShift Virtualization operators are discussed in greater detail throughout the course.

Note

Although it is possible to install the Red Hat OpenShift Virtualization operator on a single-node cluster, such an installation would not deliver high availability features.

Installation From the Command Line

To use the command-line installation method, create a YAML file to define the needed components for the subscription, and apply it by using the oc apply -f file name.yaml command.

apiVersion: v1
kind: Namespace
metadata:
  name: openshift-cnv
---
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
  name: kubevirt-hyperconverged-group
  namespace: openshift-cnv
spec:
  targetNamespaces:
    - openshift-cnv 1
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: hco-operatorhub
  namespace: openshift-cnv
spec:
  source: redhat-operators
  sourceNamespace: openshift-marketplace
  name: kubevirt-hyperconverged
  startingCSV: kubevirt-hyperconverged-operator.v4.14.1 2
  channel: "stable" 3

1

The project namespace for the virtualization operator installation (default: openshift-cnv)

2

The specific operator version to install

3

The source channel for the operator installation

After applying the subscription, create a YAML file to define the HCO operator, and apply it by using the oc apply -f file_name.yaml command.

apiVersion: hco.kubevirt.io/v1beta1
kind: HyperConverged 1
metadata:
  name: kubevirt-hyperconverged
  namespace: openshift-cnv 2
spec:

1

The required object type

2

The project namespace that is specified during operator installation

The Hostpath Provisioner and Local Storage

By using the HostPathProvisioner (HPP) custom resource, you can create virtual machines that use local node storage. In an environment without available network storage, you can deploy the hostpath provisioner to provision VMs on a node's local storage. Additionally, you can use local storage to troubleshoot performance issues for a virtual machine if you suspect that the root cause is the network storage.

With the hostpath provisioner, a virtual machine is backed by a local directory on the host node. The hostpath provisioner must be scheduled on nodes that are also scheduled for virtualization pods.

Note

For information about configuring the hostpath provisioner, refer to Configuring Local Storage for Virtual Machines at https://access.redhat.com/documentation/en-us/openshift_container_platform/4.14/html-single/virtualization/index#virt-configuring-local-storage-with-hpp

Deployment Strategy for OpenShift Virtualization Supplemental Operators and Workloads

You can specify nodes by using node selectors, affinity rules, and tolerations for different virtualization workloads. With these tools, you can specify on which nodes virtualization components are placed. Node placement rules can be specified for both virtual machines and for operators. To set node placement rules, specify Node Placement under Workloads or Infra during deployment, or edit the YAML file for the chosen object after deployment.

Node Selector

A nodeSelector object defines node placement by using labels. You can specify multiple labels, but all specified labels must be present for the node to be selected. Specify a node selector by editing the YAML of an object during or after deployment to include the key-value pair of one of the following selectors:

  • spec.config.nodePlacement.nodeSelector: Defines the node selector for operators, such as the HCO, that the Operator Lifecycle Manager (OLM) deploys during operator installation. To use the selector, you must edit the Subscription object for the hco-operatorhub during the OpenShift Virtualization operator installation.

  • spec.infra.nodePlacement.nodeSelector: Defines the nodes for supplemental components and operators, such as the Containerized Data Importer operator, that the HCO deploys, and that can be used during or after the OpenShift Virtualization operator installation.

  • spec.workloads.nodePlacement.nodeSelector: Defines the nodes that the HCO can use to deploy workloads, and that can be used during or after the OpenShift Virtualization operator installation.

Affinity

Affinity rules specify node placement with more flexibility than the node selector. When determining scheduling, you can use affinity to select or avoid specific nodes.

To establish affinity rules, adjust Affinity under Node Placement during deployment, or edit the YAML of an object to include an entry under spec.affinity.nodeAffinity.

Note

For more information about configuring node affinity, refer to Controlling Pod Placement on Nodes Using Node Affinity Rules at https://access.redhat.com/documentation/en-us/openshift_container_platform/4.14/html-single/nodes/index#nodes-scheduler-node-affinity

Toleration

Tolerations define node placement with node taints. Taints and tolerations work similarly to labels and node selectors, but include a specified effect. The effect determines whether the scheduler assigns pods with a toleration to a node with a matching taint and what to do with existing pods on a node that do not match. Specify toleration by adjusting Toleration under Node Placement during deployment, or edit the YAML file of an object to include an entry under spec.config.tolerations.

Note

For more information about configuring tolerations and taints, refer to Controlling Pod Placement Using Node Taints at https://access.redhat.com/documentation/en-us/openshift_container_platform/4.14/html-single/nodes/index#nodes-scheduler-taints-tolerations

Virtual Machine Creation

You can create virtual machines by using the OpenShift Virtualization catalog, which provides virtual machine templates and instance types for various operating systems, including Red Hat Enterprise Linux and Microsoft Windows. To access the catalog, use the OpenShift web console and navigate to VirtualizationCatalog.

You can also create virtual machines by using volumes, the Quick Start guided tour, or by applying a YAML file in the web console or from the command line.

Note

Only the default quick start guides are available within the classroom cluster. Virtualization quick start guides can be added alongside the operator installation in clusters with access to the internet.

To begin the Quick Start guided tour, select HelpQuick Starts. The Help menu is represented by a ? icon. A search field is available to find quick start guides that relate to virtualization, if available in the cluster. Several virtualization-related quick start guides exist, to introduce various OpenShift Virtualization features. These guides assist new administrators with such tasks as creating VMs from templates or volumes, and uploading a boot source.

After selecting a Quick Start guide, click Start to begin the guided tour. After completing the Quick Start guide, you can access the new virtual machine by navigating to VirtualizationVirtualMachines.

References

For more information about installing via the web console, refer to Installing OpenShift Virtualization by using the web console at https://access.redhat.com/documentation/en-us/openshift_container_platform/4.14/html-single/virtualization/index#virt-installing-virt-operator_installing-virt

For more information about installing via the command line, refer to Installing OpenShift Virtualization by using the CLI at https://access.redhat.com/documentation/en-us/openshift_container_platform/4.14/html-single/virtualization/index#installing-virt-operator-cli_installing-virt

For more information about the hostpath provisioner, refer to the Configuring local storage for virtual machines guide at https://access.redhat.com/documentation/en-us/openshift_container_platform/4.14/html-single/virtualization/index#virt-configuring-local-storage-with-hpp

For more information about specifying nodes, refer to Specifying nodes for OpenShift Virtualization components at https://access.redhat.com/documentation/en-us/openshift_container_platform/4.14/html-single/virtualization/index#virt-node-placement-virt-components

For more information about creating virtual machines, refer to the Creating VMs from Red Hat images section at https://access.redhat.com/documentation/en-us/openshift_container_platform/4.14/html-single/virtualization/index#creating-vms-from-red-hat-images/

Revision: do316-4.14-d8a6b80