Labs - KubeVirt quickstart with cloud providers

Easy install using cloud providers

KubeVirt can be used on cloud computing providers such as AWS, Azure, GCP, AliCloud.

Prepare a cloud based Kubernetes cluster

  • A kubectl client is necessary for operating a Kubernetes cluster. It is important to install a kubectl client version that matches the kubernetes version to avoid issues regarding skew.

    To install kubectl client please follow the official documentation for your system using the instructions located here.

  • Check the Kubernetes.io Turnkey Cloud Solutions guide for each cloud provider on how to build infrastructure to match your use case.

Be aware of the costs of associated with using infrastructure provided by cloud computing providers.

Future labs will require at least 30 GiB of disk space.

Deploy KubeVirt

KubeVirt can be installed using the KubeVirt operator, which manages the lifecycle of all the KubeVirt core components.

  • Use kubectl to deploy the KubeVirt operator:
    export VERSION=$(curl -s https://api.github.com/repos/kubevirt/kubevirt/releases | grep tag_name | grep -v -- '-rc' | head -1 | awk -F': ' '{print $2}' | sed 's/,//' | xargs)
    echo $VERSION
    kubectl create -f https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-operator.yaml
    

Nested virtualization

If the minikube cluster runs on a virtual machine consider enabling nested virtualization. Follow the instructions described here.

If for any reason nested virtualization cannot be enabled do enable KubeVirt emulation as follows:

kubectl create configmap kubevirt-config -n kubevirt --from-literal debug.useEmulation=true
  • Again use kubectl to deploy the KubeVirt custom resource definitions:
    kubectl create -f https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-cr.yaml
    

Verify components

By default KubeVirt will deploy 7 pods, 3 services, 1 daemonset, 3 deployment apps, 3 replica sets.

  • Check the deployment:
    kubectl get kubevirt.kubevirt.io/kubevirt -n kubevirt -o=jsonpath="{.status.phase}"
    
  • Check the components:
    kubectl get all -n kubevirt
    


Virtctl

KubeVirt provides an additional binary called virtctl for quick access to the serial and graphical ports of a VM and also handle start/stop operations.

Install

virtctl can be retrieved from the release page of the KubeVirt github page.

  • Run the following:
    VERSION=$(kubectl get kubevirt.kubevirt.io/kubevirt -n kubevirt -o=jsonpath="{.status.observedKubeVirtVersion}")
    ARCH=$(uname -s | tr A-Z a-z)-$(uname -m | sed 's/x86_64/amd64/') || windows-amd64.exe
    echo ${ARCH}
    curl -L -o virtctl https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/virtctl-${VERSION}-${ARCH}
    chmod +x virtctl
    sudo install virtctl /usr/local/bin
    

Install as Krew plugin

virtctl can be installed as a plugin via the krew plugin manager. Occurrences of virtctl <command>... can then be read as kubectl virt <command>....

  • Run the following to install:
    kubectl krew install virt
    


What’s next: Labs

After you have deployed KubeVirt you can work through the labs to help you get acquainted with KubeVirt and how it can be used to create and deploy VMs with Kubernetes.

The first lab is “Use KubeVirt”. This lab walks through the creation of a Virtual Machine Instance (VMI) on Kubernetes and then how virtctl is used to interact with its console.

The second lab is “Experiment with CDI”. This lab shows how to use the Containerized Data Importer (CDI) to import a VM image into a Persistent Volume Claim (PVC) and then how to attach the PVC to a VM as a block device.

The third lab is “KubeVirt upgrades”. This lab shows how easy and safe is to upgrade the KubeVirt installation with zero down-time.

Found a bug?

We are interested in hearing about your experience.

Please report any problems to the kubevirt.io issue tracker.