Skip to content

Instantly share code, notes, and snippets.

@jasonbrooks
Last active May 3, 2018 17:22
Show Gist options
  • Save jasonbrooks/9aa593d71d1043f18c3db25b24af9458 to your computer and use it in GitHub Desktop.
Save jasonbrooks/9aa593d71d1043f18c3db25b24af9458 to your computer and use it in GitHub Desktop.
This is based on the kubevirt quickstart from https://github.com/kubevirt/demo/blob/master/README.md, with the addition of OpenShift steps and a note that while minikube is an easy way to bring up a cluster, these steps will work w/ other sorts of kubernetes and openshift clusters. If would make sense for this quickstart to live at https://www.k…

KubeVirt Quickstart

This demo will deploy KubeVirt on an existing Kubernetes (1.9 or later) or OpenShift Origin (3.9 or later) cluster. For a quick way to bring up a Kubernetes or OpenShift Origin cluster, see Minikube and Minishift.

Quickstart

Deploy KubeVirt

KubeVirt deploys as an add-on to a Kubernetes (1.9 or later) cluster, using the kubectl tool and the following manifest file:

$ export VERSION=v0.4.1
$ kubectl create \
    -f https://github.com/kubevirt/kubevirt/releases/download/$VERSION/kubevirt.yaml

Note: The initial deployment to a new cluster can take a long time, because a number of containers have to be pulled from the internet. Use watch kubectl get --all-namespaces pods to monitor the progress.

Deploying KubeVirt on OpenShift Origin

On OpenShift Origin, the following SCCs need to be added prior kubevirt.yaml deployment:

$ oc adm policy add-scc-to-user privileged system:serviceaccount:kube-system:kubevirt-privileged
$ oc adm policy add-scc-to-user privileged system:serviceaccount:kube-system:kubevirt-controller
$ oc adm policy add-scc-to-user privileged system:serviceaccount:kube-system:kubevirt-infra

$ export VERSION=v0.4.1
$ oc apply -f https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt.yaml

Install virtctl

Note: This requires kubectl from Kubernetes 1.9 or later on the client

An additional binary is provided to get quick access to the serial and graphical ports of a VM, and handle start/stop operations. The tool is called virtctl and can be retrieved from the release page of KubeVirt:

$ curl -L -o virtctl \
    https://github.com/kubevirt/kubevirt/releases/download/$VERSION/virtctl-$VERSION-linux-amd64
$ chmod +x virtctl

Deploy a VirtualMachine

Once you deployed KubeVirt you are ready to launch a VM:

# Creating a virtual machine
$ kubectl apply -f https://raw.githubusercontent.com/kubevirt/demo/master/manifests/vm.yaml

# After deployment you can manage VMs using the usual verbs:
$ kubectl get ovms
$ kubectl get ovms -o yaml testvm

# To start an offline VM you can use
$ ./virtctl start testvm
$ kubectl get vms
$ kubectl get vms -o yaml testvm

# To shut it down again
$ ./virtctl stop testvm

# To delete
$ kubectl delete vms testvm
# To create your own
$ kubectl create -f $YOUR_VM_SPEC

Accessing VMs (serial console & spice)

# Connect to the serial console
$ ./virtctl console testvm

# Connect to the graphical display
# Note: Requires `remote-viewer` from the `virt-viewer` package.
$ ./virtctl vnc testvm

Next steps

User Guide

Now that KubeVirt is up an running, you can take a look at the user guide to understand how you can create and manage your own virtual machines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment