beawolf - Fotolia

Tip

Understand KubeVirt basics to help get you started

Getting to know KubeVirt prior to use is essential. Though it relies on core Kubernetes technology, running VMs alongside containers is something you might be unfamiliar with.

Two important technologies drive data center IT: virtualization and containerization. Of these, container-based workloads are beginning to replace virtualization-based workloads because of their portability and scalability. But what can you do if you need both? KubeVirt might be the answer you're looking for.

KubeVirt provides an extension to Kubernetes. It's most useful for organizations that want to standardize orchestrated containers in a Kubernetes environment. But KubeVirt is also ideal if you must run some workloads in VMs and want to orchestrate those VMs with Kubernetes tools.

Get to know KubeVirt basics

KubeVirt is the project that fills the gap between containers and virtualization by providing a platform where you can build, modify and deploy applications that reside in application containers and VMs. The advantage of this is KubeVirt can run containers as VMs on top of a Kubernetes infrastructure. It helps combine workloads where some parts run in VMs and other parts run in containers.

KubeVirt runs on top of Kubernetes, so you can use it in any common environment that's running Kubernetes. It does require the installation of some additional binaries, though. Virtctl is the most important because it offers control options for the VMs running on top of KubeVirt. Virtctl is the management utility you use after adding a VM to the configuration. It can manipulate the state of a container, and there is a virtctl console that enables you to connect to a console in the VM. You can manage KubeVirt VMs similarly to the way you manage traditional Kubernetes VMs.

Create KubeVirt containers and VMs using YAML files

You can create VMs the same way you create containers: using YAML manifest files. Below is a basic example of a YAML file that contains all of the necessary components:

apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachine
metadata:
  name: testvm
spec:
  running: false
  template:
    metadata:
      labels:
        kubevirt.io/size: small
        kubevirt.io/domain: testvm
    spec:
      domain:
        devices:
          disks:
            - name: containerdisk
              disk:
                bus: virtio
            - name: cloudinitdisk
              disk:
                bus: virtio
          interfaces:
          - name: default
            bridge: {}
        resources:
          requests:
            memory: 64M
      networks:
      - name: default
        pod: {}
      volumes:
        - name: containerdisk
          containerDisk:
            image: kubevirt/cirros-registry-disk-demo
        - name: cloudinitdisk
          cloudInitNoCloud:
            userDataBase64: SGkuXG4=

Manage containers and VMs with KubeVirt

KubeVirt uses KVM as a back-end hypervisor. The KVM hypervisor integrates with standard Kubernetes components, such as networking and Persistent Volumes, which you can use to store files in a way that ensures survival after a reboot. This integration makes working with KubeVirt containers easy, especially in an environment already heavily oriented with Kubernetes.

KubeVirt also brings Kubernetes to VMs. For example, you can manage scalability using the VirtualMachineInstanceReplicaSet property, which is comparable to the standard Kubernetes Replica Set. Once you start a VM as a Replica Set, you can use a service to expose it. In this case, KubeVirt uses the service as a load balancer and directs the incoming traffic to a specific VM.

However, KubeVirt isn't ideal for the migration of large virtual environments to a Kubernetes platform. It doesn't have the tools to do so, and it also lacks broad hypervisor support to make that a plausible option. The project is still relatively young, but additional features are plausible.

Dig Deeper on IT systems management and monitoring