-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepare_resources.sh
207 lines (181 loc) · 4.66 KB
/
prepare_resources.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/bin/bash -e
PROVISION_ON_NODE=$1
NAME_POSTFIX=$2
TEST_NAMESPACE=test-migration-${NAME_POSTFIX}
red=`tput setaf 1`
green=`tput setaf 2`
yellow=`tput setaf 3`
reset=`tput sgr0`
if [ -z "${PROVISION_ON_NODE}" ];
then
echo "Missing provision on node. Please specify a worker node."
echo "Usage: ./prepare-resources.sh <node_name> <0/1/2/3>"
echo "oc get node"
oc get node
exit 1
fi
if [ -z "${NAME_POSTFIX}" ];
then
echo "Missing postfix for resources name. You can specify 0, 1, 2, 3..."
echo "Usage: ./prepare-resources.sh <node_name> <0/1/2/3>"
exit 1
fi
oc new-project ${TEST_NAMESPACE}
cat > vm-cirros-dv.yaml << __EOF__
apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachine
metadata:
labels:
kubevirt.io/vm: vm-cirros-dv-${NAME_POSTFIX}
name: vm-cirros-dv-${NAME_POSTFIX}
spec:
dataVolumeTemplates:
- metadata:
annotations:
kubevirt.io/provisionOnNode: ${PROVISION_ON_NODE}
name: cirros-dv-${NAME_POSTFIX}
spec:
pvc:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100M
storageClassName: kubevirt-hostpath-provisioner
source:
http:
url: http://cnv-qe-server.rhevdev.lab.eng.rdu2.redhat.com/files/cdi-test-images/cirros_images/cirros-0.4.0-x86_64-disk.qcow2
running: false
template:
metadata:
labels:
kubevirt.io/vm: vm-datavolume
spec:
domain:
devices:
disks:
- disk:
bus: virtio
name: datavolumevolume
machine:
type: ""
resources:
requests:
memory: 64M
terminationGracePeriodSeconds: 0
volumes:
- dataVolume:
name: cirros-dv-${NAME_POSTFIX}
name: datavolumevolume
__EOF__
oc create -f vm-cirros-dv.yaml -n ${TEST_NAMESPACE}
cat > vm-fedora-dv.yaml << __EOF__
apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachine
metadata:
labels:
kubevirt.io/vm: vm-fedora-dv-${NAME_POSTFIX}
name: vm-fedora-dv-${NAME_POSTFIX}
spec:
dataVolumeTemplates:
- metadata:
annotations:
kubevirt.io/provisionOnNode: ${PROVISION_ON_NODE}
name: fedora-dv-${NAME_POSTFIX}
spec:
pvc:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storageClassName: kubevirt-hostpath-provisioner
source:
http:
url: http://cnv-qe-server.rhevdev.lab.eng.rdu2.redhat.com/files/fedora-images/Fedora-Cloud-Base-31-1.9.x86_64.qcow2
running: false
template:
metadata:
labels:
kubevirt.io/vm: vm-datavolume
spec:
domain:
devices:
disks:
- disk:
bus: virtio
name: datavolumevolume
machine:
type: ""
resources:
requests:
memory: 512M
terminationGracePeriodSeconds: 0
volumes:
- dataVolume:
name: fedora-dv-${NAME_POSTFIX}
name: datavolumevolume
__EOF__
oc create -f vm-fedora-dv.yaml -n ${TEST_NAMESPACE}
cat > vm-rhel-dv.yaml << __EOF__
apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachine
metadata:
labels:
kubevirt.io/vm: vm-rhel-dv-${NAME_POSTFIX}
name: vm-rhel-dv-${NAME_POSTFIX}
spec:
dataVolumeTemplates:
- metadata:
annotations:
kubevirt.io/provisionOnNode: ${PROVISION_ON_NODE}
name: rhel-dv-${NAME_POSTFIX}
spec:
pvc:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 12Gi
storageClassName: kubevirt-hostpath-provisioner
source:
http:
url: http://cnv-qe-server.rhevdev.lab.eng.rdu2.redhat.com/files/rhel-images/rhel-8/rhel-8.qcow2
running: false
template:
metadata:
labels:
kubevirt.io/vm: vm-datavolume
spec:
domain:
devices:
disks:
- disk:
bus: virtio
name: datavolumevolume
machine:
type: ""
resources:
requests:
memory: 512M
terminationGracePeriodSeconds: 0
volumes:
- dataVolume:
name: rhel-dv-${NAME_POSTFIX}
name: datavolumevolume
__EOF__
oc create -f vm-rhel-dv.yaml -n ${TEST_NAMESPACE}
sleep 10
echo "${yellow}oc get pvc ${reset}"
oc get pvc -n ${TEST_NAMESPACE}
echo "${yellow}oc get dv ${reset}"
oc get dv -n ${TEST_NAMESPACE}
echo "${yellow}oc get vm ${reset}"
oc get vm -n ${TEST_NAMESPACE}
virtctl start vm-cirros-dv-${NAME_POSTFIX}
virtctl start vm-rhel-dv-${NAME_POSTFIX}
sleep 10
echo "${yellow}oc get vmi ${reset}"
oc get vmi -n ${TEST_NAMESPACE}
echo "${yellow}oc get pod ${reset}"
oc get pod -o wide -n ${TEST_NAMESPACE} -w