KubeVirt & OpenShift CNV is changing the way we look at Virtual Machines, and VM orchestration, by bringing in the goodness of k8s. 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.
“I thought I am moving away from VM to containers!!! and 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 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 microservices architecture??..of breaking down the monolith to an extent, where there is also functional scalability, agility and elasticity, hence the container-based deployments & container orchestration such as k8s is critical
so in the process, enterprises end up having 2 orchestrations — VMs and Containers
Aha moment!!! how it would be as we take the first step towards cloud (lift and shift) to directly deploy VM workloads on Kube, and later worry about breaking monoliths in iterations..thats when CNVs make sense
Another key point!!! are all workloads container ready?? nope!!! I have come across so many which are not container ready…and most of them are COTS!!! so CNV all of a sudden, makes more sense…double Aha moment!!
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
and here is how it enables co-existence of VMs and Containers
The cool part is that the way you would use the storage, networking, monitoring is all like how you would in a typical k8s cluster!!!!
How does it work??
- 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
- KubeVirt CRDs:
- CDI Operator:
kubectl apply -f https://github.com/kubevirt/containerized-data-importer/releases/download/v1.18.2/cdi-operator.yaml
- CDI CRDs:
kubectl apply -f https://github.com/kubevirt/containerized-data-importer/releases/download/v1.18.2/cdi-cr.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-apiserver and uploading the file to cdi-uploadproxy.
virtctl image-upload \
--image-path= <path to ISO> \
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”
Being an IBMer, I was wondering …
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.
Here is what I copied from that blog for reference..you can go to that blog, for more details
That's all for now!!!
I will be back with a hands-on how to run Windows on OpenShift CNV…
Subscribe to FAUN topics and get your weekly curated email of the must-read tech stories, news, and tutorials 🗞️