3 printf "\n\nStart Virtlet VM provisioning E2E test\n\n"
5 TUNING_DIR="/tmp/tuning_dir"
6 CNI_PLUGINS="cni-plugins-linux-amd64-v0.8.2.tgz"
7 if !(wget https://github.com/containernetworking/plugins/releases/download/v0.8.2/$CNI_PLUGINS -P $TUNING_DIR 2>/dev/null); then
8 echo "Error downloading cni plugins for Virtlet VM provisioning"
13 if [ -f $CNI_PLUGINS ]; then
14 tar -xzvf $CNI_PLUGINS > /dev/null
15 if [ -f "tuning" ]; then
16 cp "tuning" "/opt/cni/bin/"
17 echo "Updated the tuning plugin"
19 echo "Error finding the latest tuning plugin"
27 # Create network attachment definition
30 cat <<EOF > $BPA_DIR/netattachdef-flannel-vm.yaml
31 apiVersion: "k8s.cni.cncf.io/v1"
32 kind: NetworkAttachmentDefinition
37 "cniVersion": "0.3.1",
41 "cniVersion": "0.3.1",
44 "isDefaultGateway": true
53 cat <<'EOF' > $BPA_DIR/virtlet_test_vm.yaml
57 name: virtlet-deployment
70 VirtletLibvirtCPUSetting: |
71 mode: host-passthrough
72 # This tells CRI Proxy that this pod belongs to Virtlet runtime
73 kubernetes.io/target-runtime: virtlet.cloud
74 VirtletCloudInitUserData: |
77 chpasswd: {expire: False}
78 manage_resolv_conf: True
80 nameservers: ['8.8.8.8', '8.8.4.4']
88 sudo: ALL=(ALL) NOPASSWD:ALL
92 - sed -i -e 's/^#DNS=.*/DNS=8.8.8.8/g' /etc/systemd/resolved.conf
93 - systemctl daemon-reload
94 - systemctl restart systemd-resolved
95 v1.multus-cni.io/default-network: '[
96 { "name": "flannel-vm",
97 "mac": "c2:b4:57:49:47:f1" }]'
98 VirtletRootVolumeSize: 8Gi
103 requiredDuringSchedulingIgnoredDuringExecution:
111 - name: virtlet-deployment
112 # This specifies the image to use.
113 # virtlet.cloud/ prefix is used by CRI proxy, the remaining part
114 # of the image name is prepended with https:// and used to download the image
115 image: virtlet.cloud/ubuntu/18.04
116 imagePullPolicy: IfNotPresent
117 # tty and stdin required for "kubectl attach -t" to work
125 # This memory limit is applied to the libvirt domain definition
130 # Create provisioning CR file for BPA testing
131 cat <<EOF > $BPA_DIR/e2e_bpa_test.yaml
132 apiVersion: bpa.akraino.org/v1alpha1
137 cluster: vmcluster110
138 cluster-type: virtlet-vm
143 mac-address: c2:b4:57:49:47:f1
144 PodSubnet: 172.21.64.0/18
148 # create flannel-vm net-attach-def
149 kubectl apply -f netattachdef-flannel-vm.yaml -n kube-system
151 # generate user ssh key
152 if [ ! -f "/root/.ssh/id_rsa.pub" ]; then
153 ssh-keygen -f /root/.ssh/id_rsa -P ""
156 # create ssh key secret
157 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
160 key=$(cat /root/.ssh/id_rsa.pub)
161 sed -i "s|\$ssh_key|${key}|" virtlet_test_vm.yaml
162 kubectl create -f virtlet_test_vm.yaml
165 while [[ $status != "Running" ]]
167 stats=$(kubectl get pods |grep -i virtlet-deployment)
168 status=$(echo $stats | cut -d " " -f 3)
169 if [[ $status == "Err"* ]]; then
170 echo "Error creating Virtlet VM, test incomplete"
171 kubectl delete -f virtlet_test_vm.yaml
177 echo "Virtlet VM is ready for provisioning"
179 printf "\nkubectl get pods $(kubectl get pods |grep -i virtlet-deployment | awk '{print $1}') -o json\n"
180 podjson=$(kubectl get pods $(kubectl get pods |grep -i virtlet-deployment | awk '{print $1}') -o json)
181 printf "\n$podjson\n\n"
183 # create provisioning cr
184 kubectl apply -f e2e_bpa_test.yaml
191 while [[ $status == "Running" ]]
193 stats=$(kubectl get pods |grep -i kud-cluster-vm)
194 status=$(echo $stats | cut -d " " -f 3)
195 echo "KUD install job still running"
199 if [[ $status == "Completed" ]]; then
200 printf "KUD Install completed successfully\n"
202 printf "KUD Install failed\n"
205 printf "\nPrinting kud-cluster-vm job logs....\n\n"
206 kudjob=$(kubectl get pods | grep -i kud-cluster-vm | awk '{print $1}')
207 printf "$(kubectl logs $kudjob)\n"
209 printf "\n\nBeginning E2E VM Test Teardown\n\n"
211 kubectl delete -f e2e_bpa_test.yaml
212 kubectl delete job kud-vmcluster110
213 kubectl delete configmap vmcluster110-configmap
214 kubectl delete -f virtlet_test_vm.yaml
215 rm -rf /opt/kud/multi-cluster/vmcluster110