Skip to content

Instantly share code, notes, and snippets.

apiVersion: v1
kind: Secret
metadata:
name: secret-headers
namespace: elasticsearch-demo-app
stringData:
token: "x-kubevirt-export-token:d2URaNJNFBvae3786OlT"
[awels@awels kubevirt]$ k get vmi
selecting docker as container runtime
NAME AGE PHASE IP NODENAME READY
vm-cirros 3s Scheduling False
[awels@awels kubevirt]$ k describe vmi vm-cirros
selecting docker as container runtime
Name: vm-cirros
Namespace: default
Labels: kubevirt.io/nodeName=node01
kubevirt.io/vm=vm-cirros
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: test
spec:
accessModes:
- ReadWriteOnce
storageClassName: hostpath-csi
resources:
requests:
@awels
awels / export.sh
Created November 1, 2019 20:18
import/export shell script
#!/bin/bash -e
function _kubectl(){
kubectl "$@"
}
if [ -z $1 ]; then
echo "node to export not provided"
exit 1
fi

Building Clusters with kubevirtci

One of the projects in the Kubevirt github organization is a project called kubevirtci. While this may sound like it’s the repo containing the Kubevirt CI system and scripts, that’s not completely accurate. We leverage kubevirtci for our CI process, but there’s more to the CI system than just this repo. Today, we’re not going to talk about the CI system in general, but instead we’re going to talk about the kubevirtci project, what it does, how it does it and why it’s pretty cool.

What it does

In short: Deploys a Kubernetes (or OpenShift) cluster using QEMU Virtual Machines, that run inside Docker containers. First a base image is provisioned, this image contains a stock a Kubernetes node. Then one or more of these images are deployed in the target environment to make up the cluster.

Provisioning

Building the Kubernetes Node virtual machine happens in several steps:

  1. Use a Fedora cloud image.
  2. Provision Kubernetes using Ansible onto that image.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
reclaimPolicy: Delete
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: hostpath-provisioner
labels:
app: hostpath-provisioner
spec:
selector:
matchLabels:
app: hostpath-provisioner

Getting started with storage

This document assumes you have a working development environment.

************************** THIS ONLY WORKS ON A SINGLE NODE ENVIRONMENT ****************************

Install hostPath storage class provisioner

Brazenly stolen from here as its more dynamic and flexible than my original solution.

Deploying KubeVirt on a single oVirt VM.

In this blog post we are exploring the possibilities of deploying Kube Virt on top of Open Shift which is running inside an oVirt VM. First we must prepare the environment. In my testing I created a VM with 4 cpus, 14G memory and a 100G disk. I then installed Centos 7.4 minimal on it. I also have nested virtualization enabled on my hosts, so any VMs I create can run VMs inside them. These instructions are specific to oVirt, however if you are running another virtualization platform that can nested virtualization this will also work.

For this example I chose to use a single VM for everything, but I could have done different VMs for my master/nodes/storage/etc, for simplicity I used a single VM.

Preparing the VM