blob: 47e491ca63f63f46b02e31ec2ba3180e43d8b431 [file] [log] [blame]
Vasyl Saienko775c1da2023-07-13 11:34:25 +00001EXAMPLES_DIR=$(cd $(dirname "$0")/.. && pwd)
2WORKDIR=$(cd $(dirname "$0") && pwd)
3source ${EXAMPLES_DIR}/lib.sh
4
5command=$1
6
7function run {
8 echo "Creating PVC"
9 kubectl apply -f pvc.yaml
10
11 echo "Creating VM"
12 kubectl apply -f cirros.yaml
13
14 echo "Waiting VM is Running."
15 wait_vm_state cirros-clone Running
16
17 echo "Login to VM and create some data on the volume. For example run:"
18 echo "sudo su"
19 echo "mkfs.ext4 /dev/sda"
20 echo "mkdir /mnt/vol01"
21 echo "mount -t ext4 /dev/sda /mnt/vol01"
22 echo "date > /mnt/vol01/here"
23 echo "sync"
24
25 read -p "Press any key to create clone" -n 1 -r
26 echo "Creating clone"
27
28 kubectl apply -f clone.yaml
29
30 echo "Waiting clone is created"
31 kubectl wait vmclone cirros-clone --for condition=Ready
32
33 kubectl get pvc
34 kubectl get vm
35}
36
37function cleanup {
38 kubectl delete -f cirros.yaml
39 kubectl delete -f pvc.yaml
40 kubectl delete -f clone.yaml
41
42 kubectl delete vm cirros-clone-target
43 kubectl delete vmsnapshot cirros-snapshot
44}
45
46pushd $WORKDIR
47$command
48popd