Subscribe to our blog

This tutorial demonstrates how to add OpenShift Virtualization 2.5 to an existing OpenShift 4.6 cluster and run a Fedora Linux virtual machine inside that cluster. It does not require previous knowledge of any virtualization technology. It only requires basic familiarity with OpenShift administration.

If you only have access to an OpenShift 4.5 cluster, and thus to OpenShift Virtualization 2.4, and by any reason you cannot update to a newer OpenShift release, the instructions here should work with minimum modifications. There were a few changes in the web console, and so your screens would look different, but most of the functionality required by this tutorial is unchanged.

Introducing OpenShift Virtualization

OpenShift Virtualization, based on the open source KubeVirt project, is more than an alternative to traditional hypervisors such as VMware vSphere and Red Hat Virtualization (which is based on the open source oVirt and KVM projects). It is a new technology that enables the integration of traditional, VM-based applications with cloud-native, containerized applications using a consistent set of primitives and processes based on Kubernetes. Kubernetes provides High Availability, scheduling, security, resource management, and other features to VMs the same way it provides these features to containers.

VMs managed by OpenShift Virtualization rely on existing networking and storage primitives from Kubernetes, such as Persistent Volume Claims (PVC) and Services, and also on new resource types, such as Virtual Machine Instances (VMI) and Data Volumes (DV).

Before You Begin

You can perform most tasks from OpenShift Virtualization using either the web console or the command-line interface (CLI), composed of the oc and virtctl commands. You can mix both administration methods at your leisure. The OpenShift Web console provides ease of use and a number of helpers, without preventing you from using raw YAML syntax if you need it. The CLI enables workflows that are quickly automated as shell scripts and Ansible playbooks.

To follow this tutorial, you need:

  • An existing OpenShift cluster to which you have cluster administration privileges. It could be a small lab with a few physical servers, a set of VMs or cloud instances enabled for nested virtualization, or your personal laptop with CodeReady Containers.
  • Access to the Internet from your cluster nodes to download the container images of OpenShift Virtualization and its Operator. It is possible to install OpenShift Virtualization in a disconnected environment, but it is outside the scope of this tutorial.
  • Access to an HTTP server pre-populated with Qcow2 images for your VMs from your cluster nodes. To make things simpler, I am using publicly available images from the Fedora project.
  • A default storage class with support for dynamic storage with RWX access modes. As an example, my test environment uses an open source NFS storage provider. Note that many OpenShift 4 deployment targets  (for example IaaS clouds) provide only RWO block storage as installation defaults and would not meet this requisite without further configuration.
  • Direct network access to your OpenShift cluster nodes to access your VMs using non-HTTP protocols. If you do not have that access, which is usual for cloud-based deployments of OpenShift, you will only be able to access your VMs from inside your OpenShift cluster.
  • An SSH client and knowledge about generating key pairs using it.

If you are not sure that your cluster is able to run Virtual Machines, this tutorial starts by assessing whether your cluster meets the prerequisites for running VMs managed by OpenShift Virtualization. That saves you the time and frustration of installing and configuring the virtualization operators, creating a VM, and seeing that your VM fails to start.

I am not claiming that this tutorial prepares you to deploy OpenShift Virtualization in a production environment. The goal here is being able to start exploring OpenShift Virtualization and its new resource types, CLI commands, and enhancements to the OpenShift Web Console.

Parts of This Tutorial

This tutorial is divided into a few parts that are supposed to be executed in sequence.

Part 1: Verifying That Your OpenShift Cluster Can Run Virtual Machines Using the Web Console

Part 2: Adding OpenShift Virtualization to Your OpenShift Cluster Using the Web Console

Part 3: Preparing to Create a VM Using the OpenShift Web Console

Part 4: Creating a VM Using the OpenShift Web Console

Part 5: Peeking Inside an OpenShift Virtualization VM Using the Web Console

Part 6: Accessing Your VM Using SSH and the Web Console

Conclusion and Next Steps

This tutorial provides the bare minimum to allow you to create, troubleshoot, and access VMs running in an OpenShift 4 cluster with OpenShift Virtualization. It is just the beginning, and I invite you to learn about more advanced topics, such as VM live migration, using the OpenShift Virtualization Hands-on Lab.

Though OpenShift Virtualization is still not on par with more mature virtualization platforms such as Red Hat Virtualization, it is evolving quickly. It already provides features that support a number of advanced networking and storage scenarios, some of them that require upfront planning of your OpenShift cluster and its underlying infrastructure.

Many technologies that were part of OpenShift 4 since its first release, such as Multus networking, enable these advanced scenarios. Other features from later 4.x release and new operators from Red Hat, such as OpenShift Container Storage, expand the available feature set to accommodate even more scenarios.

With time, OpenShift Virtualization will be a viable replacement for traditional Hypervisors and their management tools for most (if not all) use cases, enabling you to manage both containers and VMs from the same control plane. But the real value of OpenShift Virtualization is enabling traditional, VM-based applications to participate in streamlined DevOps processes and workflows alongside native, cloud-based applications.


About the author

Fernando lives in Rio de Janeiro, Brazil, and works on Red Hat's certification training for OpenShift, containers, and DevOps.

Read full bio

Browse by channel

automation icon

Automation

The latest on IT automation that spans tech, teams, and environments

AI icon

Artificial intelligence

Explore the platforms and partners building a faster path for AI

open hybrid cloud icon

Open hybrid cloud

Explore how we build a more flexible future with hybrid cloud

security icon

Security

Explore how we reduce risks across environments and technologies

edge icon

Edge computing

Updates on the solutions that simplify infrastructure at the edge

Infrastructure icon

Infrastructure

Stay up to date on the world’s leading enterprise Linux platform

application development icon

Applications

The latest on our solutions to the toughest application challenges

Original series icon

Original shows

Entertaining stories from the makers and leaders in enterprise tech