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/05-migrate-vm-volumes/cirros.yaml b/kubevirt/examples/05-migrate-vm-volumes/cirros.yaml
new file mode 100644
index 0000000..b203985
--- /dev/null
+++ b/kubevirt/examples/05-migrate-vm-volumes/cirros.yaml
@@ -0,0 +1,61 @@
+---
+apiVersion: kubevirt.io/v1
+kind: VirtualMachine
+metadata:
+ labels:
+ kubevirt.io/vm: cirros-migrate
+ name: cirros-migrate
+spec:
+ running: false
+ template:
+ metadata:
+ labels:
+ kubevirt.io/vm: cirros-migrate
+ spec:
+ domain:
+ devices:
+ disks:
+ - disk:
+ bus: virtio
+ name: containerdisk
+ - disk:
+ bus: virtio
+ name: cloudinitdisk
+ # - disk:
+ # bus: virtio
+ # name: host-disk
+ - disk:
+ bus: virtio
+ name: metrics
+ - disk:
+ bus: virtio
+ name: mypvcdisk
+ interfaces:
+ - name: default
+ masquerade: {}
+ resources:
+ requests:
+ memory: 128Mi
+ terminationGracePeriodSeconds: 0
+ networks:
+ - name: default
+ pod: {} # Stock pod network
+ volumes:
+ - containerDisk:
+ image: docker.io/jumpojoy/kubevirt-cirros:0.6.2
+ name: containerdisk
+ - name: mypvcdisk
+ persistentVolumeClaim:
+ claimName: cirros-migrate
+ # - hostDisk:
+ # capacity: 1Gi
+ # path: /data/disk.img
+ # type: DiskOrCreate
+ # name: host-disk
+ - name: metrics
+ downwardMetrics: {}
+ - cloudInitNoCloud:
+ userData: |
+ #!/bin/sh
+ echo 'printed from cloud-init userdata'
+ name: cloudinitdisk
diff --git a/kubevirt/examples/05-migrate-vm-volumes/pvc.yaml b/kubevirt/examples/05-migrate-vm-volumes/pvc.yaml
new file mode 100644
index 0000000..4015580
--- /dev/null
+++ b/kubevirt/examples/05-migrate-vm-volumes/pvc.yaml
@@ -0,0 +1,13 @@
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+ name: cirros-migrate
+ namespace: default
+spec:
+ accessModes:
+ - ReadWriteMany
+ resources:
+ requests:
+ storage: 2G
+ # ReadWriteMany is supported only in Block mode
+ volumeMode: Block
diff --git a/kubevirt/examples/05-migrate-vm-volumes/run.sh b/kubevirt/examples/05-migrate-vm-volumes/run.sh
new file mode 100755
index 0000000..1971190
--- /dev/null
+++ b/kubevirt/examples/05-migrate-vm-volumes/run.sh
@@ -0,0 +1,39 @@
+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 "Starting VM"
+ virtctl start cirros-migrate
+
+ echo "Waiting VM is Running."
+ wait_vm_state cirros-migrate Running
+
+ kubectl get pods -o wide
+
+ read -p "Press any key to start live migration" -n 1 -r
+ virtctl migrate cirros-migrate
+
+ for i in {1..5}; do
+ kubectl get pods -o wide
+ kubectl get vmim
+ sleep 5
+ done
+}
+
+function cleanup {
+ kubectl delete -f cirros.yaml
+ kubectl delete -f pvc.yaml
+}
+
+pushd $WORKDIR
+$command
+popd