Labs - KubeVirt quickstart with kind

Easy install using kind

Kind quickly sets up a local Kubernetes cluster on macOS, Linux, and Windows allowing software developers to quickly get started working with Kubernetes.

Prepare kind Kubernetes environment

  • 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.

  • To install kind please follow the official documentation for your system using the instructions located here.

  • Starting kind can be as simple as running the following command:

    kind create cluster
    

See the kind User Guide here for advanced start options and instructions on how to operate kind.

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://storage.googleapis.com/kubevirt-prow/release/kubevirt/kubevirt/stable.txt)
    
    echo $VERSION
    kubectl create -f "https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-operator.yaml"
    

Nested virtualization

If the kind 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 -n kubevirt patch kubevirt kubevirt --type=merge --patch '{"spec":{"configuration":{"developerConfiguration":{"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.