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/06-vm-autoscale/cirros-pool.yaml b/kubevirt/examples/06-vm-autoscale/cirros-pool.yaml
new file mode 100644
index 0000000..40d0292
--- /dev/null
+++ b/kubevirt/examples/06-vm-autoscale/cirros-pool.yaml
@@ -0,0 +1,47 @@
+apiVersion: pool.kubevirt.io/v1alpha1
+kind: VirtualMachinePool
+metadata:
+ name: cirros-pool
+spec:
+ replicas: 3
+ selector:
+ matchLabels:
+ kubevirt.io/vmpool: cirros-pool
+ virtualMachineTemplate:
+ metadata:
+ labels:
+ kubevirt.io/vmpool: cirros-pool
+ spec:
+ running: true
+ template:
+ metadata:
+ labels:
+ kubevirt.io/vm: cirros-pool
+ kubevirt.io/vmpool: cirros-pool
+ spec:
+ domain:
+ devices:
+ disks:
+ - disk:
+ bus: virtio
+ name: containerdisk
+ - disk:
+ bus: virtio
+ name: cloudinitdisk
+ resources:
+ requests:
+ memory: 128Mi
+ cpu: 1000m
+ limits:
+ memory: 256Mi
+ cpu: 2000m
+ 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/06-vm-autoscale/hpa.yaml b/kubevirt/examples/06-vm-autoscale/hpa.yaml
new file mode 100644
index 0000000..78301b6
--- /dev/null
+++ b/kubevirt/examples/06-vm-autoscale/hpa.yaml
@@ -0,0 +1,18 @@
+apiVersion: autoscaling/v2
+kind: HorizontalPodAutoscaler
+metadata:
+ name: cirros-pool
+spec:
+ maxReplicas: 10
+ minReplicas: 3
+ scaleTargetRef:
+ apiVersion: pool.kubevirt.io/v1alpha1
+ kind: VirtualMachinePool
+ name: cirros-pool
+ metrics:
+ - type: Resource
+ resource:
+ name: cpu
+ target:
+ type: Utilization
+ averageUtilization: 50
diff --git a/kubevirt/examples/06-vm-autoscale/run.sh b/kubevirt/examples/06-vm-autoscale/run.sh
new file mode 100755
index 0000000..dbd736c
--- /dev/null
+++ b/kubevirt/examples/06-vm-autoscale/run.sh
@@ -0,0 +1,37 @@
+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-pool.yaml
+
+ echo "Waiting VM is Running."
+ for i in {0..2}; do
+ wait_vm_state cirros-pool-$i Running
+ done
+
+ kubectl get vmpools
+ kubectl get pods
+
+ echo "Give some time to populate POD metris"
+ sleep 15
+
+ echo "Creating HorizontalPodAutoscaler"
+ kubectl apply -f hpa.yaml
+
+ echo "To create some load login to VM and run:"
+ echo "sudo su"
+ echo "dd if=/dev/zero of=/dev/null"
+}
+
+function cleanup {
+ kubectl delete -f cirros-pool.yaml
+ kubectl delete -f hpa.yaml
+}
+
+pushd $WORKDIR
+$command
+popd