Running KVM and VMware VMs in Container Engine for Kubernetes

KVM and VMware VMs in Container Engine for Kubernetes
This tutorial explains the steps to run Kernel-based Virtual Machine (KVM) and VMware Virtual Machines (VMs) in container engines for Kubernetes.


VMware is a California-based company that develops a virtualization platform for IT infrastructure. VMware was established in 1998 and is well known for its vSphere VMware Hypervisor. The vSphere VMware Hypervisor enables Virtualization for any type of architecture. Five different IT experts developed VMware software in the year 1998.

VMware develops various software applications related to Virtualization and is one of the leading virtualization software providers in today’s market. VMware formally launched VMware Workstation as its first product in 1999.

Later in 2001, VMware released their server application, “VMware GSX Server”. VMware then started launching additional products and services related to Virtualization in their inventory. Its products and services are categorized into Server applications and Desktop applications.

VMware is a virtualization program that helps to basically introduce multiple operating systems on a single system or server. VMware customers can run or test different operating systems without modifying anything in the system.

With the advent of microservices, customers commonly ask, “Is it possible to run legacy virtual machines (VMs) in VMware or Kernel-based Virtual Machine (KVM) with the microservices on Kubernetes, or whether they need to migrate them to containers?” The reasonable answer to that question is KubeVirt.

The KubeVirt project helps to turn Kubernetes into an orchestration engine for application containers and virtual machine workloads. It addresses the needs of development teams that have adopted or want to adopt Kubernetes but have existing virtual machine-based workloads that they can’t easily put in containers. The technology provides a unified development platform where developers can build, deploy, and modify applications that reside in both application containers and virtual machines in a standard, shared environment.

Oracle Cloud Infrastructure Container Engine for Kubernetes (referred to as OKE) provides a scalable and reliable integrated workflow platform to build, deploy, monitor, and test user’s code in the cloud. Container Engine for Kubernetes helps the user deploy, scale, and manage Kubernetes clusters in the cloud. Users can build dynamic containerized apps by incorporating Kubernetes with OCI services.

Users can deploy KubeVirt on Container Engine for Kubernetes worker nodes with VM shapes or bare metal. KubeVirt runs user’s legacy KVM or VMware VMs in nested mode if the cluster worker nodes are provisioned with virtual machine shapes.


  • Oracle Cloud Infrastructure command-line interface (CLI)
  • The Container Engine for Kubernetes kubectl CLI 
  • Users can also use Cloud Shell, a browser-based terminal accessible from the Oracle Cloud Infrastructure Console. 



In order to deploy KubeVirt with Container Engine for Kubernetes, follow the below steps:


Step 1: Deploy the KubeVirt Operator 
  • First, run the Container Engine for the Kubernetes cluster and NodePool nodes.
  • Next, set the version environment variable to be used on commands by executing the following :


export KUBEVIRT_VERSION=$(curl -s | grep tag_name | grep -v -- - | sort -V | tail -1 | awk -F':' '{print $2}' | sed 's/,//' | xargs)



  • Execute the following command to deploy the KubeVirt operator by using the kubectl tool:


 kubectl create -f${KUBEVIRT_VERSION}/kubevirt-operator.yaml


  • Then, make sure that the KubeVirt operator is running by executing the following command:


[root@kvmvbox ~]# kubectl get pods -n kubevirt
virt-operator-6b5455546b-56dvx     1/1     Running   0          39h
virt-operator-6b5455546b-5pwdj     1/1     Running   0          39h


  • Finally, check for the virtualization extensions. The shapes should have nested Virtualization enabled by default when the user uses Oracle Cloud Infrastructure VM shapes with Oracle Linux images, and the cpuinfo file should have the VMX flag. For the same, execute the following command:


 egrep 'svm|vmx' /proc/cpuinfo


Step 2: Deploy KubeVirt 
  • In order to deploy KubeVirt by creating dedicated custom resources, execute the following command:


 kubectl create -f${KUBEVIRT_VERSION}/kubevirt-cr.yaml


  • After that, check the deployment by executing the following command: 


 kubectl get pods -n kubevirt


KVM and VMware VMs in Container Engine for Kubernetes 1


Step 3: Install virtctl

Another binary gives quick access to a virtual machine’s graphical and serial ports and handles stop and start operations. The tool is called virtctl, and users can retrieve it from the release page of KubeVirt by executing the following commands:


curl -L -o virtctl \${KUBEVIRT_VERSION}/virtctl-${KUBEVIRT_VERSION}-linux-amd64
chmod +x virtctl


Step 4: Test KubeVirt 

Finally, test the KubeVirt with Container Engine for Kubernetes by running legacy VMware VMs or KVM, along with containers. KubeVirt provides some labs that let the user test it before trying on VMware VMs or legacy KVM.

The first lab, Use KubeVirt, walks the user through creating a VM instance on Kubernetes and then shows them how to use virtctl to interact with its console.

The second lab, Experiment with the Containerized Data Importer (CDI), shows the user how to use the CDI to import a virtual machine image into a Persistent Volume Claim (PVC), and then how to define a VM to use the PVC.


Running VMware VM and KVMs in Container Engine 

If the user plans to run a VMware VM or KVM in Container Engine for Kubernetes, they must first convert the disks to a raw format. Two free utilities can help the user do that: Oracle VirtualBox VBoxManage and QEMU disk image utility.

  • VBoxManage is the command-line interface for Oracle virtual machine VirtualBox. Users can use it to control Oracle VM VirtualBox from the command line of the user’s host operating system. VBoxManage exposes all the virtualization engine features, and it lets you convert disks into different formats. Use the following command in the command-line interface to convert VM disks to a raw format:


VBoxManage clonehd --format RAW kvm_qcow2_OR_VMware_vmdk_disk disk-name.img


  • QEMU disk image utility (qemu-img) also lets the user convert disks into other formats. In order to install it on a system running Oracle Linux, execute the following command:


 sudo yum install qemu-img


After that, execute the following command to convert the VM disks to a raw format:


qemu-img convert kvm_qcow2_OR_VMware_vmdk_disk -O raw disk-name.img


After the disks are converted, users can make them available in Container Engine for Kubernetes. Users have a few different choices:

  • They can upload the disk into the worker nodes and run it with the hostpath.
  • Users can create a Docker image of the raw disk and upload it into a public registry like OCI Registry.
  • They can also clone a disk and create a persistent volume claim (PVC) with it.



This tutorial presents the steps to run Kernel-based Virtual Machine (KVM) and VMware Virtual Machines (VMs) in container engines for Kubernetes. Hope this tutorial was helpful, and do reach out to us if you have any queries or suggestions.

Share this post

Services to Explore

Stay up to date!

Stay up to date with the Web Hosting, Cloud and Server Management Industry News and Tutorials!

We will send you only the relevant emails, and we respect your privacy. Please review our privacy policy for more info.

Docker Consulting Services

Focus on your business, and let us work on your Docker Projects!
From what you are reading, it seems you are interested in Kubernetes and related technologies. If you have a moment to spare, please take a look at our Kubernetes Consulting Services, which might interest you even more!
Kubernetes Consulting Services

Value-Added Services

We have services that can help you run a successful business. With us, you don't have to worry about these areas because our experts will take care of it for you.

ServerHealers uses cookies.