# KubeVirt Download all scripts and binaries from the latest [relase](https://github.com/kubevirt/kubevirt/releases). By the time of writing, the lastest release is `0.31.0` which is still in alpha. The `kubevirt` projects comes with the binary `virtctl` which facilitates vm managements. I suggest against using it. It is best to use `kubectl` only. P.S. The `kubevirt` [documentation](https://kubevirt.io/user-guide/#/) recommend installing `virtctl` with the `kubectl` addon manager `skew`. Not only is the use of `virtctl` discouraged, installing `virtctl` with `skew` is even worse, as addons on `skew` are not curated by the `skew` maintainers. ## Install KubeVirt on Minikube This tutorial is a continuation of the [`minikube` tutorial](https://hackmd.io/@hsukuotsan/BymZWSekD). In the `LXD` vm you created previously, install the `QEMU/KVM` hypervisor: ``` apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils ``` Check if the hypervisor is functional with `virt-host-validate qemu`. Ideally, all checks should pass. In my case, however, I passed all checks but one: `No ACPI DMAR table found, IOMMU either disabled in BIOS or not supported by this hardware platform`, yet this seems to have no affect on my using `kubevirt`. One could probably ignore this warning?! Go to the release page and find two assets attached to the latest stable release: ``` kubevirt-operator.yaml kubevirt-cr.yaml ``` Get their url and apply them to minikube with (it happened to be of version `0.31.0`): ``` kubectl apply -f https://github.com/kubevirt/kubevirt/releases/download/v0.31.0/kubevirt-operator.yaml kubectl apply -f https://github.com/kubevirt/kubevirt/releases/download/v0.31.0/kubevirt-cr.yaml ``` Wait for the deployment to become available: ``` kubectl -n kubevirt wait kv kubevirt --for condition=Available ``` List the resources associated with the namespace `kubevirt`: ``` kubectl get pods -n kubevirt ``` ## Managing VMs Most operations are done via **patches**. You can patch the `virt-handler` DaemonSet post-deployment to restrict it to a specific subset of nodes with a nodeSelector. For example, to restrict the DaemonSet to only nodes with the "region=primary" label: <sup>[&dagger;](https://kubevirt.io/user-guide/#/installation/installation?id=restricting-virt-handler-daemonset)<sup> ``` kubectl patch ds/virt-handler -n kubevirt -p \ '{"spec": {"template": {"spec": {"nodeSelector": {"region": "primary"}}}}}' ``` Start a vm: <sup>[&Dagger;](https://kubevirt.io/labs/kubernetes/lab1.html)<sup> ``` kubectl patch virtualmachine <vm> --type merge -p \ '{"spec":{"running":true}}' ``` Stop a vm: <sup>[&Dagger;](https://kubevirt.io/labs/kubernetes/lab1.html)<sup> ``` kubectl patch virtualmachine myvm --type merge -p \ '{"spec":{"running":false}}' ``` Check on the vm: <sup>[&Dagger;](https://kubevirt.io/labs/kubernetes/lab1.html)<sup> ``` kubectl get vmis kubectl get vmis -o yaml testvm ``` [CDI](https://github.com/kubevirt/containerized-data-importer)