{{announcement.body}}
{{announcement.title}}

KubeVirt and OpenShift CNV: Why It Makes Sense

DZone 's Guide to

KubeVirt and OpenShift CNV: Why It Makes Sense

KubeVirt and OpenShift CNV are changing Virtual Machines, and VM orchestration, by bringing in the goodness of k8s, and colocating VMs with containers.

· Cloud Zone ·
Free Resource

KubeVirt & OpenShift CNV is changing the way we look at Virtual Machines, and VM orchestration, by bringing in the goodness of Kubernetes. This blog, I will share my thoughts about how this will transform our journey to the cloud.

Why KubeVirt & CNV?

I had various questions when I heard about container-native Virtualization (CNV) & KubeVirt. I was asking myself, "Why would I run a VM inside a container?"

It didn't take much time to realize, that the enterprises have already invested in stabilizing a lot of core business systems that are running on VMs. As the first safest step towards "journey to the cloud", is to "lift-shift" the workloads quickly to the cloud. This has an immediate impact on the TCO, and helps move more towards the OPEX model, and leverage the elasticity of the cloud!

Now if they have to lift and shift, there are a lot of systems that are already virtualized and working on VMs, it makes a lot of sense to quickly move these workloads!

Now, why can't they just use the matured VM orchestrations?

Now again if you look at the journey to the cloud, it would not stop at lift and shift. To leverage the real value of the cloud, we have to modernize the applications and move towards cloud-native architectures and consume native services- which means the next obvious step is to go towards a microservices architecture of breaking down the monolith to an extent, where there is also functional scalability, agility and elasticity, hence the container-based deployments and container orchestration such as Kubernetes is critical

So in the process, enterprises end up having 2 orchestrations, VMs and containers.

How would it be to directly deploy VM workloads on Kube, and later worry about breaking monoliths in iterations? That's when CNVs make sense

Are all workloads container-ready? No. I have come across so many which are not container ready, and most of them are commerical. 

So What is KubeVirt?

KubeVirt comes to the rescue for managing VMs as Pods!

KubeVirt is an open-source project that provides a way to run VMs as Pods and co-exist in the k8s cluster. It leverages KVM (linux kernel hypervisor) to provide container-native virtualisation (CNV)

Here is how it stacks up:

Kubevirt

and here is how it enables the co-existence of VMs and containers.

VMs and container

The cool part is that the way you would use the storage, networking, monitoring is all like how you would in a typical Kubernetes cluster!

How Does It Work?

Architecture
  • virt-controller: Responsible for cluster-wide virtualization .
  • virt-handler: responsible for handling operations to change a VM to meet the required state.
  • virt-launcher: Each VM is created in a Pod, virt-launcher runs in the primary container of the pod, to provide the cgroups and namespaces which will be used to host the VM process
  • libvirtd: manages the life-cycle of the VM process, stays in every pod.
  • qemu: is the open-source machine emulator that runs the VM

We will need KuberVirt and Container Data Importer (CDI) Operators and CRDs to be applied to our cluster (using kubectl apply -f).

CDI is a utility to import, upload, and clone VM images.

KubeVirt Operator:

kubectl apply -f https://github.com/kubevirt/kubevirt/releases/download/v0.26.0/kubevirt-operator.yaml 


CDI Operator:
kubectl apply -f https://github.com/kubevirt/containerized-data-importer/releases/download/v1.18.2/cdi-operator.yaml


Convert VMs to KubeVirt

The disk image of the VM needs to be used as the bootable image for KubeVirt VM. PV with the disk image needs to be attached as a CD-ROM to the VM... and using virtctl image-upload command the VM is automatically created. Here is a sample of how a windows ISO can be used to create an image on PV of the requested size to cdi-apiserverand uploading the file to cdi-uploadproxy.

Shell  




xxxxxxxxxx
1


 
1
virtctl image-upload \
2
   --image-path= <path to ISO> \
3
   --pvc-name=iso-win2k12 \
4
   --access-mode=ReadOnlyMany \
5
   --pvc-size=5G \
6
   --uploadproxy-url=https://10.96.164.35:443 \
7
   --insecure \
8
   --wait-secs=240


The data inside is by default ephemeral, however, PVC can be used like how we typically use for container, and persist the data.

All this is cool!!!

You can monitor the VMs as how you would monitor containers with Prometheus

Enter the "OpenShift CNV "

What does OpenShift bring above and beyond this!!!

OpenShift CNV is the Red Hat version of KubeVirt, that allows you to run VMs alongside containers on OpenShift Platform!!! isn't that cool!! so you get all the goodies that you would get with Red Hat OpenShift Container Platform (vs DYI K8s) & the ease of DevOps & Management.

Refer to this blog https://www.openshift.com/blog/blog-openshift-virtualization-whats-new-with-virtualization-from-red-hat

Here is what I copied from that blog for reference..you can go to that blog, for more details

Redhat and openshift virtualization

That's all for now!!!

I will be back with a hands-on how to run Windows on OpenShift CNV...





Topics:
contaienrs, crio, docker, kubernetes, kubevirt, openshift, vm

Published at DZone with permission of A B Vijay Kumar . See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}