4 printf "\n\nStart Virtlet VM provisioning E2E test\n\n"
6 TUNING_DIR="/tmp/tuning_dir"
7 CNI_PLUGINS="cni-plugins-linux-amd64-v0.8.2.tgz"
8 if !(wget https://github.com/containernetworking/plugins/releases/download/v0.8.2/$CNI_PLUGINS -P $TUNING_DIR 2>/dev/null); then
9 echo "Error downloading cni plugins for Virtlet VM provisioning"
14 if [ -f $CNI_PLUGINS ]; then
15 tar -xzvf $CNI_PLUGINS > /dev/null
16 if [ -f "tuning" ]; then
17 cp "tuning" "/opt/cni/bin/"
18 echo "Updated the tuning plugin"
20 echo "Error finding the latest tuning plugin"
28 # Create network attachment definition
31 cat <<EOF > $BPA_DIR/netattachdef-flannel-vm.yaml
32 apiVersion: "k8s.cni.cncf.io/v1"
33 kind: NetworkAttachmentDefinition
38 "cniVersion": "0.3.1",
42 "cniVersion": "0.3.1",
45 "isDefaultGateway": true
54 cat <<'EOF' > $BPA_DIR/virtlet_test_vm.yaml
58 name: virtlet-deployment
71 VirtletLibvirtCPUSetting: |
72 mode: host-passthrough
73 # This tells CRI Proxy that this pod belongs to Virtlet runtime
74 kubernetes.io/target-runtime: virtlet.cloud
75 VirtletCloudInitUserData: |
78 chpasswd: {expire: False}
79 manage_resolv_conf: True
81 nameservers: ['8.8.8.8', '8.8.4.4']
89 sudo: ALL=(ALL) NOPASSWD:ALL
93 - sed -i -e 's/^#DNS=.*/DNS=8.8.8.8/g' /etc/systemd/resolved.conf
94 - systemctl daemon-reload
95 - systemctl restart systemd-resolved
96 v1.multus-cni.io/default-network: '[
97 { "name": "flannel-vm",
98 "mac": "c2:b4:57:49:47:f1" }]'
99 VirtletRootVolumeSize: 8Gi
100 VirtletVCPUCount: "2"
104 requiredDuringSchedulingIgnoredDuringExecution:
112 - name: virtlet-deployment
113 # This specifies the image to use.
114 # virtlet.cloud/ prefix is used by CRI proxy, the remaining part
115 # of the image name is prepended with https:// and used to download the image
116 image: virtlet.cloud/ubuntu/18.04
117 imagePullPolicy: IfNotPresent
118 # tty and stdin required for "kubectl attach -t" to work
126 # This memory limit is applied to the libvirt domain definition
131 # Create provisioning CR file for BPA testing
132 cat <<EOF > $BPA_DIR/e2e_bpa_test.yaml
133 apiVersion: bpa.akraino.org/v1alpha1
138 cluster: vmcluster110
139 cluster-type: virtlet-vm
144 mac-address: c2:b4:57:49:47:f1
145 PodSubnet: 172.21.64.0/18
149 # create flannel-vm net-attach-def
150 kubectl apply -f netattachdef-flannel-vm.yaml -n kube-system
152 # generate user ssh key
153 if [ ! -f "/root/.ssh/id_rsa.pub" ]; then
154 ssh-keygen -f /root/.ssh/id_rsa -P ""
157 # create ssh key secret
158 kubectl create secret generic ssh-key-secret --from-file=id_rsa=/root/.ssh/id_rsa --from-file=id_rsa.pub=/root/.ssh/id_rsa.pub
161 key=$(cat /root/.ssh/id_rsa.pub)
162 sed -i "s|\$ssh_key|${key}|" virtlet_test_vm.yaml
163 kubectl create -f virtlet_test_vm.yaml
166 while [[ $status != "Running" ]]
168 stats=$(kubectl get pods |grep -i virtlet-deployment)
169 status=$(echo $stats | cut -d " " -f 3)
170 if [[ $status == "Err"* ]]; then
171 echo "Error creating Virtlet VM, test incomplete"
172 kubectl delete -f virtlet_test_vm.yaml
178 echo "Virtlet VM is ready for provisioning"
180 printf "\nkubectl get pods $(kubectl get pods |grep -i virtlet-deployment | awk '{print $1}') -o json\n"
181 podjson=$(kubectl get pods $(kubectl get pods |grep -i virtlet-deployment | awk '{print $1}') -o json)
182 printf "\n$podjson\n\n"
184 # create provisioning cr
185 kubectl apply -f e2e_bpa_test.yaml
192 while [[ $status == "Running" ]]
194 stats=$(kubectl get pods |grep -i kud-cluster-vm)
195 status=$(echo $stats | cut -d " " -f 3)
196 echo "KUD install job still running"
200 if [[ $status == "Completed" ]]; then
201 printf "KUD Install completed successfully\n"
203 printf "KUD Install failed\n"
206 printf "\nPrinting kud-cluster-vm job logs....\n\n"
207 kudjob=$(kubectl get pods | grep -i kud-cluster-vm | awk '{print $1}')
208 printf "$(kubectl logs $kudjob)\n"
210 printf "\n\nBeginning E2E VM Test Teardown\n\n"
212 kubectl delete -f e2e_bpa_test.yaml
213 kubectl delete job kud-vmcluster110
214 kubectl delete --ignore-not-found=true configmap vmcluster110-configmap
215 kubectl delete -f virtlet_test_vm.yaml
216 rm -rf /opt/kud/multi-cluster/vmcluster110