Chapter 1
Introduction to VM Migration and OpenShift Virtualization
Chapter Summary
# Chapter 1: Introduction to VM Migration and OpenShift Virtualization The virtualization landscape is currently undergoing its most significant transformation in over a decade. As organizations look to consolidate their infrastructure and bridge the gap between legacy monolithic applications and m...
Chapter 1: Introduction to VM Migration and OpenShift Virtualization
The virtualization landscape is currently undergoing its most significant transformation in over a decade. As organizations look to consolidate their infrastructure and bridge the gap between legacy monolithic applications and modern microservices, the "siloed" approach to managing Virtual Machines (VMs) and Containers is becoming a liability.
In this chapter, we will explore the technical foundations of Red Hat OpenShift Virtualization, the architectural shift it represents, and why the Ansible Automation Platform (AAP) is the essential glue for executing high-scale, enterprise-grade migrations.
The Convergence of VMs and Containers
For years, IT departments maintained two distinct stacks: one for virtualized workloads (typically VMware or oVirt) and one for containerized workloads (Kubernetes/OpenShift). OpenShift Virtualization, based on the open-source KubeVirt project, eliminates this duality by allowing VMs to run natively within a Kubernetes cluster.
Why OpenShift Virtualization?
OpenShift Virtualization isn't just a "me-too" hypervisor. It treats a VM as a first-class citizen within the Kubernetes ecosystem. This means:
- Unified Networking: VMs and Pods share the same Software Defined Network (SDN).
- Unified Storage: VMs use the same Container Storage Interface (CSI) drivers as your containers.
- Unified Operations: Your monitoring (Prometheus), logging (Elasticsearch), and CI/CD pipelines work identically for both.
"The goal of OpenShift Virtualization is not to simply replace your hypervisor, but to modernize the way you manage virtual resources by applying DevOps and GitOps principles to legacy workloads."
Understanding the Architecture
To migrate effectively, an advanced practitioner must understand what happens under the hood. When you run a VM on OpenShift, it is encapsulated within a Linux container (Pod).
- The Virt-Launcher Pod: Every running VM corresponds to a Pod. The process inside the pod handles the QEMU/KVM instance.text
virt-launcher - Custom Resource Definitions (CRDs): OpenShift Virtualization introduces new objects like (the definition of the VM) andtext
VirtualMachine(the running instance).textVirtualMachineInstance - CDI (Containerized Data Importer): This is the engine that handles data movement. It pulls disks from external sources (S3, HTTP, or VMware) and converts them into OpenShift-native .text
DataVolumes
Real-World Example: The "Pet" VM vs. The "Cattle" VM
In a traditional environment, a database server is a "Pet"—manually configured and carefully maintained. By migrating it to OpenShift Virtualization, you can wrap that "Pet" in a "Cattle" framework. You can use Kubernetes
ServiceThe Role of Ansible Automation Platform (AAP)
If OpenShift Virtualization is the destination, Ansible is the vehicle. While the Migration Toolkit for Virtualization (MTV) provides a GUI for migrations, advanced users quickly find that GUI-driven migrations don't scale to thousands of VMs across multiple business units.
Ansible provides:
- Pre-migration Validation: Checking if the source VM has compatible disk formats or specialized hardware pass-through that might break on OpenShift.
- Orchestration: Shutting down the source VM, triggering the migration, and updating DNS/Load Balancers simultaneously.
- Post-migration Configuration: Running or specific playbooks to reconfigure networking and internal services once the VM lands in its new home.text
cloud-init
Code Example: Defining a VM in OpenShift via Ansible
Using the
kubernetes.core.k8syaml- name: Create a Virtual Machine in OpenShift kubernetes.core.k8s: state: present definition: apiVersion: kubevirt.io/v1 kind: VirtualMachine metadata: name: legacy-db-server namespace: production-vms spec: running: true template: spec: domain: cpu: cores: 4 resources: requests: memory: 8Gi devices: disks: - name: rootdisk disk: bus: virtio volumes: - name: rootdisk dataVolume: name: legacy-db-root-dv
Migration Strategies: Rehost vs. Replatform
As an advanced architect, you must decide which migration "path" each workload takes.
1. Rehosting (Lift and Shift)
This is the most common use case for OpenShift Virtualization. You move the VM bit-for-bit.
- Pros: Low risk, fast.
- Cons: You carry the "technical debt" of the old OS into the new environment.
- Ansible's Role: Automated discovery of vCenter inventories and mapping them to OpenShift Namespaces.
2. Replatforming
Here, you might use Ansible to spin up a new VM on OpenShift using a standardized RHEL template and then use Ansible to migrate the data or application configuration from the old VM to the new one.
- Pros: Clean OS, updated security patches, optimized for KubeVirt.
- Cons: Higher effort per VM.
Practical Tips and Best Practices
Networking: The Multus Factor
Standard Kubernetes pods usually have one interface. However, legacy VMs often require multiple NICs for management, backup, and storage traffic.
- Tip: Familiarize yourself with Multus CNI. It allows you to attach multiple network interfaces to a VM Pod, enabling bridge networking that keeps your VMs on their original VLANs.
Storage: Think "Thin"
When migrating, ensure your
StorageClass- Practice: Use DataVolumes rather than raw PersistentVolumeClaims (PVCs). DataVolumes are "smart" and can handle the orchestration of the CDI to import your image automatically.
The "Migration Hook"
Ansible is excellent for "hooks." A migration hook is a script or playbook that runs at a specific stage (e.g., Pre-migration to stop a database service, or Post-migration to update an IP in a CMDB like NetBox).
yaml# Example: Post-migration hook to update CMDB - name: Update NetBox with new VM location netbox.netbox.netbox_virtual_machine: netbox_url: "{{ netbox_url }}" netbox_token: "{{ netbox_token }}" data: name: "{{ vm_name }}" cluster: "OpenShift-Prod-01" status: "active" state: present
Preparing for the Journey
In the upcoming chapters, we will dive deep into the technical implementation. We will build an automated pipeline that:
- Discovers VMs in a VMware vSphere environment.
- Assesses them for compatibility using Ansible-driven logic.
- Executes the migration using the Migration Toolkit for Virtualization (MTV) API.
- Verifies the health of the VM on OpenShift.
Migration is not just about moving data; it’s about moving trust. By the end of this book, you will have the tools to move mission-critical workloads with the confidence that only automation can provide.
Summary Checklist for Chapter 1
- [ ] Understand that OpenShift Virtualization is KubeVirt-based.
- [ ] Recognize that a VM on OpenShift is a Pod, benefitting from Kubernetes scheduling.
- [ ] Identify Ansible as the primary tool for orchestrating the migration lifecycle.
- [ ] Differentiate between the andtext
VirtualMachineobjects.textVirtualMachineInstance - [ ] Prepare for "Network thinking"—moving from single-interface pods to multi-interface (Multus) VMs.
In Chapter 2, we will set up our laboratory environment, including the installation of the OpenShift Virtualization Operator and the configuration of the Migration Toolkit for Virtualization.
What You Learned
- 1
OpenShift Virtualization integrates VMs into Kubernetes for streamlined management, eliminating the need for separate stacks.
- 2
It offers unified networking and storage for both VMs and containers, enhancing operational efficiency.
- 3
The Ansible Automation Platform is critical for executing scalable, enterprise-grade migrations within this new architecture.
📖 Key Terms
A feature of Red Hat OpenShift that allows users to manage both containerized applications and virtual machines in a unified platform.
A comprehensive suite of tools for automating cloud provisioning, configuration management, application deployment, and many other IT tasks.
The process of moving virtual machines from one physical host to another or from one virtualization environment to another with minimal downtime.
Automating the deployment, scaling, and management of containerized applications, typically using tools like Kubernetes.
A design approach that ensures a certain level of operational performance, usually uptime, by redundancy and failover mechanisms in the event of a failure.
Quiz requires login
Sign in to take the quiz and track your progress.