Add examples with kubevirt
* Add helpers to install kubevirt and its dependencies
* Add examples how to use kubevirt
Related-Prod: PRODX-3456
Change-Id: I3ade65df5f8ddff39f35605104851833d74690a1
diff --git a/kubevirt/examples/10-add-volume/run.sh b/kubevirt/examples/10-add-volume/run.sh
new file mode 100755
index 0000000..d4d8a57
--- /dev/null
+++ b/kubevirt/examples/10-add-volume/run.sh
@@ -0,0 +1,45 @@
+EXAMPLES_DIR=$(cd $(dirname "$0")/.. && pwd)
+WORKDIR=$(cd $(dirname "$0") && pwd)
+source ${EXAMPLES_DIR}/lib.sh
+
+command=$1
+
+function run {
+ echo "Creating PVC with CDI"
+ echo "Downloading cirros"
+ if [[ ! -f ${TMP_DIR}/cirros-0.6.2-x86_64-disk.img ]]; then
+ wget https://download.cirros-cloud.net/0.6.2/cirros-0.6.2-x86_64-disk.img -O ${TMP_DIR}/cirros-0.6.2-x86_64-disk.img
+ cp ${TMP_DIR}/cirros-0.6.2-x86_64-disk.img ${TMP_DIR}/disk.img
+ fi
+
+ echo "Uploading cirros to PVC."
+ UPLOADPROXY_URL=https://$(kubectl get nodes -o wide| tail -1 | awk '{print $6}'):31119
+ virtctl image-upload pvc cirros-add-volume --size 5G --image-path=${TMP_DIR}/disk.img --insecure --uploadproxy-url ${UPLOADPROXY_URL}
+
+ kubectl get pvc
+ kubectl get pods
+
+ echo "Creating VM"
+ kubectl apply -f cirros-add-volume.yaml
+
+ echo "Waiting VM is Running."
+ wait_vm_state cirros-add-volume Running
+
+ read -p "Press any key to add volume" -n 1 -r
+ echo "Adding volume"
+ virtctl addvolume cirros-add-volume --volume-name=cirros-add-volume
+
+ read -p "Press any key to remove volume" -n 1 -r
+ echo "Removing volume"
+ virtctl removevolume cirros-add-volume --volume-name=cirros-add-volume
+}
+
+function cleanup {
+ kubectl delete -f cirros-add-volume.yaml
+ kubectl delete datavolume cirros-add-volume
+ kubectl delete pvc cirros-add-volume
+}
+
+pushd $WORKDIR
+$command
+popd