From 81a2c8bf2e268a3cf2a9be7928a5771ffa065cd7 Mon Sep 17 00:00:00 2001 From: Sergi Jimenez Date: Thu, 12 Jul 2018 01:47:02 +0200 Subject: [PATCH] issue #28 Add KubeVirt add-on * Add-on install file. * Features file. * README. --- add-ons/kubevirt/README.md | 37 ++++++++++++++++++++ add-ons/kubevirt/kubevirt.addon | 15 +++++++++ test/integration/features/kubevirt.feature | 39 ++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 add-ons/kubevirt/README.md create mode 100644 add-ons/kubevirt/kubevirt.addon create mode 100644 test/integration/features/kubevirt.feature diff --git a/add-ons/kubevirt/README.md b/add-ons/kubevirt/README.md new file mode 100644 index 0000000..88d003a --- /dev/null +++ b/add-ons/kubevirt/README.md @@ -0,0 +1,37 @@ +# Deploying KubeVirt on OpenShift + +* This addon provides an easy way to install [KubeVirt](https://kubevirt.io/) on [Minishift](https://github.com/minishift/minishift). +* Prerequisites: + + * [Installed and running](https://docs.openshift.org/latest/minishift/getting-started/installing.html) Minishift + * [Installed](https://docs.openshift.org/latest/minishift/command-ref/minishift_oc-env.html) OpenShift CLI + +## Start Minishift + +* The deployment works with Minishift default resources - 2 CPUs and 2 GB RAM. Nevertheless we prefer to allocate more memory (as much as you'd need to run your VMs) available to KubeVirt. Start Minishift using following command to provide more RAM. + + ```shell + $ minishift start --memory=8GB + ``` + +## Add-on installation + +* Clone this repository onto your local machine and then install the add-on via: + + ```shell + $ minishift addons install + ``` + +## Start KubeVirt + +* Deploy all KubeVirt components. + + ```shell + $ minishift addons apply kubevirt + ``` + +## Variables + +*KUBEVIRT_VERSION* is mandatory and must be set to one of the [KubeVirt available releases](https://github.com/kubevirt/kubevirt/releases), by default it's set to *v0.7.0-alpha.2*. + +> **NOTE**: Due to issues on KubeVirt (e.g. [kubevirt/kubevirt#1196](https://github.com/kubevirt/kubevirt/issues/1196)) *KUBEVIRT_VERSION* is set to *v0.7.0-alpha.2* and it's not recommended to use a newer one until the issues are fixed. diff --git a/add-ons/kubevirt/kubevirt.addon b/add-ons/kubevirt/kubevirt.addon new file mode 100644 index 0000000..8bf4567 --- /dev/null +++ b/add-ons/kubevirt/kubevirt.addon @@ -0,0 +1,15 @@ +# Name: kubevirt +# Description: Installs KubeVirt. For more information visit https://kubevirt.io +# Required-Vars: KUBEVIRT_VERSION +# Var-Defaults: KUBEVIRT_VERSION=v0.7.0-alpha.2 +# OpenShift-Version: >=3.9.0 + +echo Deploying KubeVirt... + +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 +oc apply -f https://github.com/kubevirt/kubevirt/releases/download/#{KUBEVIRT_VERSION}/kubevirt.yaml +oc adm policy add-cluster-role-to-user kubevirt.io:edit developer + +echo Deployment applied, KubeVirt is starting up! diff --git a/test/integration/features/kubevirt.feature b/test/integration/features/kubevirt.feature new file mode 100644 index 0000000..15898e0 --- /dev/null +++ b/test/integration/features/kubevirt.feature @@ -0,0 +1,39 @@ +@kubevirt +Feature: KubeVirt add-on + KubeVirt addon starts KubeVirt + + @minishift-only + Scenario: User install kubevirt add-on + Given stdout of command "minishift addons list" does not contain "kubevirt" + When executing "minishift addons install ../../add-ons/kubevirt" succeeds + Then stdout should contain "Addon 'kubevirt' installed" + + Scenario: Minishift starts + Given Minishift has state "Does Not Exist" + When executing "minishift start --memory 4GB" succeeds + Then Minishift should have state "Running" + + Scenario: Applying the add-on + When executing "minishift addons apply kubevirt" succeeds + Then stdout should contain "Deployment applied, KubeVirt is starting up!" + + Scenario: KubeVirt is ready + Given Minishift has state "Running" + When executing "minishift openshift service list" succeeds + Then stdout should contain "virt-api" + + Scenario: DaemonSet virt-handler is ready + Given user waits "60" seconds + When executing "oc get ds -n kube-system --as system:admin" succeeds + Then stdout should match "virt-handler(\s+1){5}" + + Scenario: ReplicaSet virt-api and virt-controller are ready + Given user waits "60" seconds + When executing "oc get rs -n kube-system --as system:admin" succeeds + Then stdout should match "virt-api-\w{10}(\s+2){3}" + And stdout should match "virt-controller-\w{10}(\s+2){3}" + + Scenario: Deleting Minishift + Given Minishift has state "Running" + When executing "minishift delete --force" succeeds + Then Minishift should have state "Does Not Exist"