It took 7 years to bring virtual machines into the Kubernetes world

It took 7 years to bring virtual machines into the Kubernetes world
It took 7 years to bring virtual machines into the Kubernetes world

With the development of cloud computing and container technology, Kubernetes has become the industry standard and leader, providing users with a powerful, flexible and scalable platform to deploy and manage various types of applications.

However, for some applications that are difficult to containerize, such as traditional enterprise applications, legacy systems, or applications that require special hardware support, virtual machines are still a necessary and effective solution. How to run and manage virtual machines on Kubernetes, and how to achieve interoperability and consistency between containers and virtual machines, is an urgent problem that needs to be solved.

This is the background and goal of the KubeVirt project.

KubeVirt is an open source project that enables virtual machines to be deployed, consumed and managed by Kubernetes like containers. It provides a unified platform that allows users to build cloud-native applications using containers or virtual machines according to different needs. 

The KubeVirt project was launched in 2016 and is jointly promoted and contributed by Red Hat, IBM, Google, Intel, SUSE and other companies and organizations. After 7 years of unremitting efforts, KubeVirt released v1.0.0 in July 2023, marking that it has reached a production-ready level and has a healthy community. (Before this, it has been used in production environments by many companies)

In this article, I will review the development history of KubeVirt, introduce the core functions and advantages of KubeVirt, and analyze the future prospects and challenges of KubeVirt.

The development history of KubeVirt

The idea of ​​KubeVirt can be traced back to 2015.

At the first KubeCon, Fabian Deutsch, an engineer at Red Hat, raised a question: Can a virtual machine be run on Kubernetes? 

The answer at the time was uncertain, but the question aroused a lot of interest and discussion. Over the next year, Fabian Deutsch and his colleagues began some prototype and experimental work, exploring different solutions and technologies. In the end, they chose to use libvirt and QEMU to run and manage virtual machines on Kubernetes.

At the end of 2016, the KubeVirt project was officially launched and open sourced on GitHub. The main goal of the project is to provide a Kubernetes native virtualization API and runtime, allowing users to use VirtualMachine and VirtualMachineInstance to define and manage virtual machines just like Pods and Deployments. 

The main challenge of the project is how to integrate and coordinate virtual machines with Kubernetes’ resource model, scheduler, network, storage and other components.

Over the next few years, the KubeVirt project went through multiple phases and versions of iterations and improvements. Some of the important milestones include:

  • At the end of 2017, KubeVirt implemented basic virtual machine creation and deletion functions and released version v0.1.0.
  • In early 2018, KubeVirt redesigned VirtualMachine’s API and released version v0.2.0.
  • In mid-2018, KubeVirt was compatible with Kubernetes network and offline virtual machine support, and released version v0.3.0.
  • At the end of 2018, KubeVirt supported initialization of empty PV, as well as liveness and readiness, and released versions v0.9.0 ~ v0.11.0.
  • In mid-2019, KubeVirt was supported virtctl migrateand version v0.21.0 was released.
  • In early 2022, KubeVirt removed the old support for GPU devices, which can be defined in a unified way, and released version v0.50.0.
  • In mid-2023, KubeVirt released v1.0.0.

In fact, it can be seen that although KubeVirt has not released the v1.0 version, it has maintained a relatively frequent release frequency. In this process, the KubeVirt community continues to grow and become active. As of now, KubeVirt’s GitHub repository has more than 270 contributors, more than 17k commits, and more than 4.5k stars.

KubeVirt’s users and partners are also constantly increasing, including IBM, Google, Intel, SUSE, Red Hat, Huawei, VMware, Canonical, Rancher and many other well-known companies and organizations.

KubeVirt’s Core features and Benefits

The core function of KubeVirt is to run and manage virtual machines on Kubernetes. In order to realize this function, KubeVirt provides the following solutions:

Virtualization API

KubeVirt defines a set of Kubernetes native virtualization APIs, allowing users to use VirtualMachine and VirtualMachineInstance to define and manage virtual machines just like Pods and Deployments. VirtualMachine is a declarative resource type that represents a desired virtual machine state. 

VirtualMachineInstance is a real-time resource type that represents a running virtual machine instance. Users can create, update, delete or query these resources through YAML files or kubectl commands. 

For example:

apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
  annotations:
    kubevirt.io/latest-observed-api-version: v1
    kubevirt.io/storage-observed-api-version: v1
  creationTimestamp: "2024-01-26T10:25:41Z"
  finalizers:
  - kubevirt.io/virtualMachineControllerFinalize
  generation: 1
  name: testvm
  namespace: default
  resourceVersion: "12691"
  uid: d5509381-5f21-438b-9440-cb7c9ee82b37
spec:
  running: false
  template:
    metadata:
      creationTimestamp: null
      labels:
        kubevirt.io/domain: testvm
        kubevirt.io/size: small
    spec:
      architecture: amd64
      domain:
        devices:
          disks:
          - disk:
              bus: virtio
            name: containerdisk
          - disk:
              bus: virtio
            name: cloudinitdisk
          interfaces:
          - masquerade: {}
            name: default
        machine:
          type: q35
        resources:
          requests:
            memory: 64M
      networks:
      - name: default
        pod: {}
      volumes:
      - containerDisk:
          image: quay.io/kubevirt/cirros-container-disk-demo
        name: containerdisk
      - cloudInitNoCloud:
          userDataBase64: SGkuXG4=
        name: cloudinitdisk

This YAML file defines a virtual machine named testvm, which has 2 disks. One of the disks is a container image and the other disk is a cloud initialization configuration. Users can create this virtual machine through kubectl apply -f testvm.yaml, or query its status through kubectl get vm testvm.

TECKY $ kubectl get vms
NAME     AGE     STATUS    READY
testvm   3m20s   Running   True

Virtualization Runtime

KubeVirt implements a set of virtualization runtimes that allow users to run and manage virtual machines on any node in a Kubernetes cluster. 

KubeVirt’s runtime mainly consists of the following components:

  • virt-controller: Responsible for monitoring and tuning the status of virtual machines, and handling virtual machine life cycle events, such as creation, deletion, start, stop, migration, etc.
  • virt-handler: Responsible for performing virtual machine operations on each node, such as starting, stopping, pausing, restoring, etc. It is also responsible for communicating with libvirt and QEMU, as well as collecting and reporting virtual machine performance metrics.
  • virt-operator: Responsible for starting and managing libvirt and QEMU processes on each node.
  • virt-api: Responsible for providing the service endpoint of the virtualization API, as well as validating and transforming user requests.
TECKY $ kubectl get pods -n kubevirt
NAME                               READY   STATUS    RESTARTS   AGE
virt-operator-6c649b9567-m2tbl     1/1     Running   0          6m36s
virt-operator-6c649b9567-kqfnl     1/1     Running   0          6m36s
virt-api-66859f4c8d-tnf68          1/1     Running   0          5m53s
virt-controller-8545966675-wskv9   1/1     Running   0          5m17s
virt-controller-8545966675-z68gb   1/1     Running   0          5m17s
virt-handler-h8zx4                 1/1     Running   0          5m17s

KubeVirt’s runtime adopts Kubernetes’ native architecture and patterns, allowing users to manage virtual machines like containers. For example:

  • Users can use the kubectl logs command to view the logs of the virtual machine.

Network Solutions

KubeVirt supports a variety of network plug-ins and solutions, allowing users to provide appropriate network connections and configurations for virtual machines according to different needs. KubeVirt’s network solutions mainly include the following:

  • Pod Network: This is the simplest and most commonly used network solution, which allows virtual machines to share the Pod’s network namespace and interface. In this way, the virtual machine can access network resources inside and outside the cluster like a Pod, and can be accessed by network resources inside and outside the cluster.
  • Multi-network: This is a more flexible and advanced network solution that allows virtual machines to have multiple network interfaces and connect to different network planes. In this way, virtual machines can use different network policies and configurations according to different uses and scenarios. For example, a virtual machine can have a network interface for management, a network interface for data transfer, and a network interface for public network access.
  • Bridged Network: This is a network solution closer to traditional virtualization that allows virtual machines to directly use the physical network interfaces and addresses on the node. This way, the virtual machine can communicate with other devices on the node just like a physical machine and can use the network security and monitoring tools on the node.
  • SR-IOV networking: This is a higher performance and lower latency networking scheme that allows virtual machines to directly use the virtual functions of the physical network card on the node. In this way, the virtual machine can bypass the overhead of the software layer, directly access the resources of the hardware layer, and enjoy the acceleration and optimization of the hardware layer.

Storage Solutions

KubeVirt supports a variety of storage plug-ins and solutions, allowing users to provide appropriate storage space and configuration for virtual machines according to different needs. KubeVirt’s storage solutions mainly include the following:

  • Container disk: This is a container image-based storage solution that allows a virtual machine to use the container image as its root disk. In this way, virtual machines can be started and stopped quickly like containers, and you can enjoy the convenience and security of container images.
  • Persistent Volumes: This is a Kubernetes-based storage solution that allows virtual machines to use Kubernetes Persistent Volumes (PV) and Persistent Volume Claims (PVC) as their data disks. In this way, virtual machines can use Kubernetes storage classes (StorageClass) to dynamically apply for and release storage space like Pods, and can use Kubernetes storage plug-ins to connect to different storage backends.
  • Host disk: This is a node-based storage solution that allows virtual machines to use local disks or directories on the node as their data disks. This way, virtual machines can take advantage of the storage performance and capacity on the node and avoid network layer overhead and latency.
  • CDI disk: This is a storage solution based on the CDI (Containerized Data Importer) project. It allows users to import or clone data from different sources (such as HTTP, S3, Registry, etc.) into Kubernetes persistent volumes, and can automatically Convert data formats (such as qcow2, raw, vmdk, etc.). In this way, users can easily migrate or copy existing virtual machine images or data to Kubernetes, and use KubeVirt to run and manage them.

Mirror Solution

KubeVirt supports a variety of image plug-ins and solutions, allowing users to provide appropriate image sources and configurations for virtual machines according to different needs. KubeVirt’s mirroring solutions mainly include the following:

  • Container image: This is an image solution based on container technology, which allows users to use the container image as the root disk or CD-ROM of a virtual machine. In this way, users can take advantage of the advantages of container technology, such as lightweight, fast startup, easy distribution, secure isolation, etc.
  • Virtual machine image: This is an image solution based on traditional virtualization technology, which allows users to use virtual machine images as the initial configuration of virtual machines.

The future of KubeVirt

Now that KubeVirt has released v1.1,1 now , Red Hat, as a founding member, carries KubeVirt in OpenShift virtualization. Kubermatic, Rancher, Google, Oracle, etc. also provide products with built-in KubeVirt. Civo , Puzl, Platform9 and others are bringing KubeVirt to the cloud and offering hosted and self-managed products.

If you are preparing for Kubernetes certification, check out all certification guides here :

Check last Kubernetes Exams (CKAD , CKA , CKS) Coupon Page to get discounts on certification registration.

Kubernetes Certification Coupon CKAD CKA CKS

Author

0 Shares:
You May Also Like
Make Kubernetes simpler! 8 AI Tools You Must Know
Read More

Make Kubernetes simpler! 8 AI Tools You Must Know

Table of Contents Hide OverviewK8sGPTInstallPrerequisiteskubectl-aiInstall via Homebrew:Install via Krew:DemoKoPylotFunctionOperating principleKopilotInstallKubectl-GPTInstallPrerequisitesKube-CopilotInstallSet operationKubernetes ChatGPT botDemoAppilotAuthor Overview Kubernetes users inevitably face…