![Search icon](https://hackernoon.imgix.net/search-new.png?w=19&h=19)
Virtualization has been a cornerstone of modern IT infrastructure for decades, but the rise of cloud-native technologies and containerization has exposed limitations in traditional virtualization approaches. IT teams find themselves juggling separate management tools and workflows for virtual machines (VMs) and containers, leading to inefficiencies and increased complexity.
OpenShift, with its integrated virtualization capabilities powered by KubeVirt, bridges this gap by enabling the unified management of both virtual machines (VMs) and containers within the same OpenShift environment. This article covers the core concepts of Openshift Virtualization, explores its advantages, and examines how it allows organizations to improve their operations and modernize IT infrastructure.
Modern virtualization has different forms, each addressing specific requirements and use cases. Let's explore the primary options: traditional, cloud-based, and OpenShift virtualization.
Virtualization has transformed how we use computing resources. At its core, virtualization involves software known as a hypervisor that creates an abstraction layer on top of physical hardware. This allows running multiple, isolated virtual machines on a single physical server. Each VM simulates its own dedicated set of hardware—CPU, memory, disk, and network—and runs a complete operating system and applications on it.
Traditional virtualization has delivered benefits like server consolidation, increased hardware utilization, improved workload isolation, and enhanced disaster recovery. Popular hypervisors include VMware vSphere, Microsoft Hyper-V, and KVM (Kernel-based Virtual Machine).
Cloud-based virtualization takes the concept further by using the resources of cloud providers. Infrastructure as a service (IaaS) offers virtualized compute instances on demand. With cloud-based virtualization, you benefit from rapid scaling and a pay-as-you-go model, eliminating the need for hardware maintenance and providing the flexibility to deploy workloads across different geographic locations. Key examples include AWS EC2, Azure Virtual Machines, and Google Compute Engine.
OpenShift Virtualization is a feature built into OpenShift that seamlessly integrates virtual machine management with containerized workloads. Built upon KubeVirt, it extends the container orchestration capabilities of Kubernetes to manage the lifecycles of virtual machines.
The emphasis here is on integration: OpenShift Virtualization provides a unified platform to manage both VMs and containers side by side. This translates into reduced complexity, streamlined management using familiar Kubernetes tools, the potential to modernize legacy applications, and the opportunity to use your existing Kubernetes expertise.
OpenShift Virtualization's integration with Kubernetes unlocks a range of compelling benefits that address specific IT challenges.
Let's illustrate the main concepts of OpenShift Virtualization with a hands-on example. We'll walk through the process of deploying a simple virtual machine using a YAML configuration and kubectl
commands.
Note: This is a simplified example. More complex VM configurations might involve multiple disks, advanced networking, or integration with cloud-init
for customization.
Prerequisites:
kubectl
command-line tool.Here's a detailed YAML example for creating a virtual machine using specific OpenShift Virtualization features and data sources. This example includes the configuration for a VM that uses a Red Hat Enterprise Linux 9 image from a pre-configured data source in OpenShift:
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
labels:
app: <vm_name>
name: <vm_name>
spec:
dataVolumeTemplates:
- apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
name: <vm_name>
spec:
sourceRef:
kind: DataSource
name: rhel9
namespace: openshift-virtualization-os-images
storage:
resources:
requests:
storage: 30Gi
running: false
template:
metadata:
labels:
kubevirt.io/domain: <vm_name>
spec:
domain:
cpu:
cores: 1
sockets: 2
threads: 1
devices:
disks:
- disk:
bus: virtio
name: rootdisk
- disk:
bus: virtio
name: cloudinitdisk
interfaces:
- masquerade: {}
name: default
rng: {}
features:
smm:
enabled: true
firmware:
bootloader:
efi: {}
resources:
requests:
memory: 8Gi
evictionStrategy: LiveMigrate
networks:
- name: default
pod: {}
volumes:
- dataVolume:
name: <vm_name>
name: rootdisk
- cloudInitNoCloud:
userData: |-
#cloud-config
user: cloud-user
password: '<password>'
chpasswd: { expire: False }
name: cloudinitdisk
Explanation of key parameters:
Deploy the VM by applying the YAML file with the OpenShift command-line interface:
$ oc create -f <vm_manifest_file>.yaml
After the VM definition is successfully created, you can start the VM using virtctl, a command-line tool specifically designed for managing virtual machines in environments that use KubeVirt:
$ virtctl start <vm_name>
This sequence allows you to create and start a virtual machine in OpenShift Virtualization, leveraging specific configurations and OpenShift's virtualization capabilities. Adjust <vm_name>, <password>, and <vm_manifest_file>.yaml with actual values before running the commands.
Accessing the virtual machine can vary based on its operating system and network configuration. Here are several methods provided by OpenShift to access VMs:
Web-based VNC Console: OpenShift Virtualization provides a built-in VNC console accessible through the web-based OpenShift console. This allows you to interact with the VM’s graphical interface directly from your browser.
SSH: If the VM has SSH configured and is on a reachable network, you can connect using an SSH client. This requires network access to the VM and appropriate SSH credentials.
Serial Console: OpenShift allows access to a VM's serial console via the OpenShift console. This can be particularly useful for troubleshooting issues when SSH or VNC may not be available.
Virtctl Tool: Using the virtctl command-line tool, you can access the graphical or serial console of a VM. This method is handy for users who prefer command-line tools or need to automate console access.
The typical commands are:
virtctl vnc <vm_name>
for VNC access, or
virtctl console <vm_name>
for serial console access.
Each of these access methods might require specific configurations on the VM or within the OpenShift environment to function correctly. Ensure that necessary roles and permissions are set to allow users to access VM consoles according to your organizational security policies. Always check the current OpenShift documentation for updates or changes to these processes, as tools and methods may evolve with new OpenShift versions.
OpenShift Virtualization's versatility makes it an excellent choice for a variety of scenarios. Let's look at some common use cases.
OpenShift offers a path to modernize legacy applications without requiring full-scale rearchitecting. You can “lift and shift" existing VM-based applications to OpenShift, gradually breaking them down into microservices while maintaining functionality. Applications that help with OpenShift backup and restore enhance this modernization process with robust backup and recovery capabilities for VMs, minimizing the risk of data loss or downtime during the transition and reducing the costs associated with modernization initiatives.
For organizations spanning on-premises and cloud environments, OpenShift creates a common management layer for diverse infrastructure. OpenShift Virtualization lets you deploy and manage VM-based workloads consistently across both cloud and on-prem data centers, allowing for a seamless hybrid cloud experience.
OpenShift Virtualization helps you rapidly set up complex development and testing environments that include both traditional VMs and containers. This ability to mimic production-like environments with VMs accelerates software delivery cycles and helps uncover potential issues earlier. And if something goes wrong, backup tools can help with point-in-time, application-consistent backups for virtual machines running within OpenShift Virtualization. This ensures that the entire VM state, including configuration, data, and any dependencies are preserved for rapid recovery.
Increasingly, organizations are exploring the strategic deployment of standalone clusters specifically for running VMs within OpenShift Virtualization. This trend is partly driven by Red Hat’s positioning of OpenShift Virtualization as a viable alternative to traditional virtualization platforms like VMware. By separating VM workloads into dedicated clusters, companies can optimize performance and management for these environments. Such a strategy not only enhances operational efficiency but also aligns with modern IT demands for specialized infrastructure solutions. Feedback from early adopters suggests that separate clusters for VMs and containers can lead to more tailored, effective management and scaling of resources according to specific workload requirements.