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/04-memdump-vm/cirros.yaml b/kubevirt/examples/04-memdump-vm/cirros.yaml
new file mode 100644
index 0000000..0be94da
--- /dev/null
+++ b/kubevirt/examples/04-memdump-vm/cirros.yaml
@@ -0,0 +1,36 @@
+---
+apiVersion: kubevirt.io/v1
+kind: VirtualMachine
+metadata:
+ labels:
+ kubevirt.io/vm: cirros-memdump
+ name: cirros-memdump
+spec:
+ running: false
+ template:
+ metadata:
+ labels:
+ kubevirt.io/vm: cirros-memdump
+ 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
+ - cloudInitNoCloud:
+ userData: |
+ #!/bin/sh
+ echo 'printed from cloud-init userdata'
+ name: cloudinitdisk
diff --git a/kubevirt/examples/04-memdump-vm/run.sh b/kubevirt/examples/04-memdump-vm/run.sh
new file mode 100755
index 0000000..0f84c21
--- /dev/null
+++ b/kubevirt/examples/04-memdump-vm/run.sh
@@ -0,0 +1,36 @@
+EXAMPLES_DIR=$(cd $(dirname "$0")/.. && pwd)
+WORKDIR=$(cd $(dirname "$0") && pwd)
+source ${EXAMPLES_DIR}/lib.sh
+
+command=$1
+
+function run {
+ echo "Creating VM"
+ kubectl apply -f cirros.yaml
+
+ echo "Starting VM"
+ virtctl start cirros-memdump
+
+ echo "Waiting VM is Running."
+ wait_vm_state cirros-memdump Running
+
+ echo "Creating memorydump"
+ virtctl memory-dump get cirros-memdump --claim-name=cirros-memdump --create-claim
+
+ sleep 5
+
+ echo "Creating ubuntu pod"
+ kubectl apply -f ubuntu.yaml
+
+}
+
+function cleanup {
+ kubectl delete pod ubuntu-memdump --force --grace-period=0
+ kubectl delete -f cirros.yaml
+ kubectl delete -f ubuntu.yaml
+ kubectl delete pvc cirros-memdump
+}
+
+pushd $WORKDIR
+$command
+popd
diff --git a/kubevirt/examples/04-memdump-vm/ubuntu.yaml b/kubevirt/examples/04-memdump-vm/ubuntu.yaml
new file mode 100644
index 0000000..67a0a4c
--- /dev/null
+++ b/kubevirt/examples/04-memdump-vm/ubuntu.yaml
@@ -0,0 +1,18 @@
+apiVersion: v1
+kind: Pod
+metadata:
+ name: ubuntu-memdump
+spec:
+ containers:
+ - name: ubuntu
+ image: ubuntu
+ command:
+ - sleep
+ - infinity
+ volumeMounts:
+ - mountPath: "/data"
+ name: memdump
+ volumes:
+ - name: memdump
+ persistentVolumeClaim:
+ claimName: cirros-memdump