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/11-clone-vm/cirros.yaml b/kubevirt/examples/11-clone-vm/cirros.yaml
new file mode 100644
index 0000000..f9f67e8
--- /dev/null
+++ b/kubevirt/examples/11-clone-vm/cirros.yaml
@@ -0,0 +1,39 @@
+---
+apiVersion: kubevirt.io/v1
+kind: VirtualMachine
+metadata:
+  labels:
+    kubevirt.io/vm: cirros-clone
+  name: cirros-clone
+spec:
+  running: true
+  template:
+    metadata:
+      labels:
+        kubevirt.io/vm: cirros-clone
+    spec:
+      domain:
+        devices:
+          disks:
+          - disk:
+              bus: virtio
+            name: containerdisk
+          - disk:
+              bus: virtio
+            name: cloudinitdisk
+        resources:
+          requests:
+            memory: 128Mi
+      terminationGracePeriodSeconds: 0
+      volumes:
+      - containerDisk:
+          image: docker.io/jumpojoy/kubevirt-cirros:0.6.2
+        name: containerdisk
+      - name: mypvcdisk
+        persistentVolumeClaim:
+          claimName: cirros-clone
+      - cloudInitNoCloud:
+          userData: |
+            #!/bin/sh
+            echo 'printed from cloud-init userdata'
+        name: cloudinitdisk
diff --git a/kubevirt/examples/11-clone-vm/clone.yaml b/kubevirt/examples/11-clone-vm/clone.yaml
new file mode 100644
index 0000000..b75273c
--- /dev/null
+++ b/kubevirt/examples/11-clone-vm/clone.yaml
@@ -0,0 +1,27 @@
+kind: VirtualMachineClone
+apiVersion: "clone.kubevirt.io/v1alpha1"
+metadata:
+  name: cirros-clone
+
+spec:
+  # source & target definitions
+  source:
+    apiGroup: kubevirt.io
+    kind: VirtualMachine
+    name: cirros-clone
+  target:
+    apiGroup: kubevirt.io
+    kind: VirtualMachine
+    name: cirros-clone-target
+
+  # labels & annotations definitions
+  labelFilters:
+    - "*"
+    - "!someKey/*"
+  annotationFilters:
+    - "anotherKey/*"
+
+  # other identity stripping specs:
+  #newMacAddresses:
+  #  interfaceName: "00-11-22"
+  #newSMBiosSerial: "new-serial"
diff --git a/kubevirt/examples/11-clone-vm/pvc.yaml b/kubevirt/examples/11-clone-vm/pvc.yaml
new file mode 100644
index 0000000..746908e
--- /dev/null
+++ b/kubevirt/examples/11-clone-vm/pvc.yaml
@@ -0,0 +1,12 @@
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+  name: cirros-clone
+  namespace: default
+spec:
+  accessModes:
+  - ReadWriteOnce
+  resources:
+    requests:
+      storage: 2G
+  volumeMode: Filesystem
diff --git a/kubevirt/examples/11-clone-vm/restore.yaml b/kubevirt/examples/11-clone-vm/restore.yaml
new file mode 100644
index 0000000..8cfede4
--- /dev/null
+++ b/kubevirt/examples/11-clone-vm/restore.yaml
@@ -0,0 +1,10 @@
+apiVersion: snapshot.kubevirt.io/v1alpha1
+kind: VirtualMachineRestore
+metadata:
+  name: cirros-snapshot
+spec:
+  target:
+    apiGroup: kubevirt.io
+    kind: VirtualMachine
+    name: cirros-snapshot
+  virtualMachineSnapshotName: cirros-snapshot
diff --git a/kubevirt/examples/11-clone-vm/run.sh b/kubevirt/examples/11-clone-vm/run.sh
new file mode 100755
index 0000000..47e491c
--- /dev/null
+++ b/kubevirt/examples/11-clone-vm/run.sh
@@ -0,0 +1,48 @@
+EXAMPLES_DIR=$(cd $(dirname "$0")/.. && pwd)
+WORKDIR=$(cd $(dirname "$0") && pwd)
+source ${EXAMPLES_DIR}/lib.sh
+
+command=$1
+
+function run {
+    echo "Creating PVC"
+    kubectl apply -f pvc.yaml
+
+    echo "Creating VM"
+    kubectl apply -f cirros.yaml
+
+    echo "Waiting VM is Running."
+    wait_vm_state cirros-clone Running
+
+    echo "Login to VM and create some data on the volume. For example run:"
+    echo "sudo su"
+    echo "mkfs.ext4 /dev/sda"
+    echo "mkdir /mnt/vol01"
+    echo "mount -t ext4 /dev/sda /mnt/vol01"
+    echo "date > /mnt/vol01/here"
+    echo "sync"
+
+    read -p "Press any key to create clone" -n 1 -r
+    echo "Creating clone"
+
+    kubectl apply -f clone.yaml
+
+    echo "Waiting clone is created"
+    kubectl wait vmclone cirros-clone --for condition=Ready
+
+    kubectl get pvc
+    kubectl get vm
+}
+
+function cleanup {
+    kubectl delete -f cirros.yaml
+    kubectl delete -f pvc.yaml
+    kubectl delete -f clone.yaml
+
+    kubectl delete vm cirros-clone-target
+    kubectl delete vmsnapshot cirros-snapshot
+}
+
+pushd $WORKDIR
+$command
+popd
diff --git a/kubevirt/examples/11-clone-vm/snapshot.yaml b/kubevirt/examples/11-clone-vm/snapshot.yaml
new file mode 100644
index 0000000..f7b9a98
--- /dev/null
+++ b/kubevirt/examples/11-clone-vm/snapshot.yaml
@@ -0,0 +1,9 @@
+apiVersion: snapshot.kubevirt.io/v1alpha1
+kind: VirtualMachineSnapshot
+metadata:
+  name: cirros-snapshot
+spec:
+  source:
+    apiGroup: kubevirt.io
+    kind: VirtualMachine
+    name: cirros-snapshot