Manually Deploying Kubevirt on OpenShift Origin

It has been enjoyable to learn the Kubevirt code base and coding in Go.  However, unless the code gets deployed to servers, no one will use it in production.  I’ve been learning OpenShift as an integration point for Kubevirt.  Here are my notes for getting it up and running.  This is not quite production grade, but should help write a proper deployment mechanism.

Please note, as of KubeVirt v0.17 installing KubeVirt directly via manifests is deprecated. KubeVirt is now deployed using the operator pattern.

The rest of this document is maintained for historical value only.

Using openshift-ansible.  I originally had to apply one patch but it got merged!

Here is my inventory file for a two node deployment.

munchlax openshift_node_labels="{'region': 'infra'}"
dialga openshift_node_labels="{'region': 'infra'}"

Running the playbook like this:

ansible-playbook -i  ~/devel/local-openshift-ansible/inventory.ini  ~/devel/openshift-ansible/playbooks/byo/config.yml

I should have modified that to be able to schedule on the master node0, but it can be done after the fact like this:

oadm manage-node munchlax --schedulable=true

Had to edit the manifests in kubevirt:

Move the manifests over to the master, in order to use the service account to create the various resources:

scp /home/ayoung/go/src/* ansible@munchlax:manifests/

Note the differences from the source:

$ diff -u virt-api.yaml
--- 2017-06-06 12:01:46.077594982 -0400
+++ virt-api.yaml 2017-06-07 10:47:03.048151082 -0400
@@ -7,7 +7,7 @@
 - port: 8183
 targetPort: virt-api
 externalIPs :
- - "{{ master_ip }}"
+ - ""
 app: virt-api
@@ -23,17 +23,18 @@
 - name: virt-api
- image: {{ docker_prefix }}/virt-api:{{ docker_tag }}
+ image: kubevirt/virt-api:latest
 imagePullPolicy: IfNotPresent
 - "/virt-api"
 - "--port"
 - "8183"
 - "--spice-proxy"
- - "{{ master_ip }}:3128"
+ - ""
 - containerPort: 8183
 name: "virt-api"
 protocol: "TCP"
- master
+ munchlax

All of the referenced images need to be “latest” instead of devel.

For both libvirt and virt-handler I use the privilegeduser service account.  The master node (munchlax) has a ~/.kubeconf file set up to allow operations on the kube-system.

#For libvirt we need a service user:
oc create serviceaccount -n default privilegeduser
oc adm policy add-scc-to-user privileged -ndefault -z privilegeduser

Starting the services in the dependency order is not necessary, but I do it anyway

kubectl create -f vm-resource.yaml
kubectl create -f migration-resource.yaml
kubectl create -f virt-api.yaml
kubectl create -f virt-controller.yaml
kubectl create -f libvirt.yaml
kubectl create -f virt-handler.yaml

As of this writing, kubevirt only support VMs in the default namespace. The VM launches using a few iSCSI volumes.  I need to create the iscsi volume in the same namespace as the VM:

kubectl create -f iscsi-demo-target.yaml --namespace default

I’m going to regret this but…overpowering the ayoung user to be god on the cluster.

oc create user ayoung
oadm policy add-role-to-user edit ayoung 
#Don't trust ayoung...
oadm policy add-cluster-role-to-user cluster-admin ayoung
# he can't even keep track of his car keys and cellphone, and
# you make him admin on your cluster?
oadm policy add-role-to-user admin system:serviceaccount:kube-system:default

Try to create a vm:

oc login
kubectl config set-context $(kubectl config current-context) --namespace=default
kubectl create -f ~/go/src/
#wait for a bit and then
kubectl get vms -o json | jq '. | .items[0] | .status | .phase'

Still todo:  Spice, console, and migrations.

1 thought on “Manually Deploying Kubevirt on OpenShift Origin

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.