3 printf "\n\nStart Remote Virtlet VM provisioning E2E test\n\n"
5 # remote compute provisioned and kube config available
6 source ~/ICN/latest/icn/env/lib/common.sh
7 CLUSTER_NAME=bpa-remote
8 KUBECONFIG=--kubeconfig=/opt/kud/multi-cluster/${CLUSTER_NAME}/artifacts/admin.conf
9 APISERVER=$(kubectl ${KUBECONFIG} config view --minify -o jsonpath='{.clusters[0].cluster.server}')
10 TOKEN=$(kubectl ${KUBECONFIG} get secret $(kubectl ${KUBECONFIG} get serviceaccount default -o jsonpath='{.secrets[0].name}') -o jsonpath='{.data.token}' | base64 --decode )
11 call_api $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure
15 printf "\nRemote Kubernetes Cluster Install did not complete successfully\n"
17 printf "\niRemote Kubernetes Cluster Install was successful\n"
20 # create virtlet VM in remote compute
21 printf "Create remote Virtlet VM ...\n"
22 key=$(cat /opt/kud/multi-cluster/.ssh/id_rsa.pub)
23 cp ../deploy/virtlet-deployment-sample.yaml bpa_remote_virtletvm.yaml
24 sed -i "s|\$ssh_key|${key}|" bpa_remote_virtletvm.yaml
25 kubectl ${KUBECONFIG} create -f bpa_remote_virtletvm.yaml
28 while [[ $status != "Running" ]]
30 stats=$(kubectl ${KUBECONFIG} get pods |grep -i virtlet-deployment)
31 status=$(echo $stats | cut -d " " -f 3)
32 if [[ $status == "Err"* ]]; then
33 echo "Error creating remote Virtlet VM, test incomplete"
34 kubectl ${KUBECONFIG} delete -f bpa_remote_virtletvm.yaml
39 echo "Remote Virtlet VM is ready for provisioning"
41 printf "\nkubectl ${KUBECONFIG} get pods $(kubectl ${KUBECONFIG} get pods |grep -i virtlet-deployment | awk '{print $1}') -o json\n"
42 podjson=$(kubectl ${KUBECONFIG} get pods $(kubectl ${KUBECONFIG} get pods |grep -i virtlet-deployment | awk '{print $1}') -o json)
43 printf "\n$podjson\n\n"
45 printf "Provision remote Virtlet VM ...\n"
46 kubectl ${KUBECONFIG} apply -f bpa_remote_virtletvm_cr.yaml
48 #Check Status of remote kud job pod
51 while [[ $status == "Running" ]]
53 echo "KUD install job still running"
55 stats=$(kubectl ${KUBECONFIG} get pods |grep -i kud-)
56 status=$(echo $stats | cut -d " " -f 3)
59 if [[ $status == "Completed" ]];
61 printf "KUD Install Job completed\n"
62 printf "Checking cluster status\n"
64 printf "KUD Install Job failed\n"
67 #Print logs of Job Pod
68 jobPod=$(kubectl ${KUBECONFIG} get pods|grep kud-)
69 podName=$(echo $jobPod | cut -d " " -f 1)
70 printf "\nNow Printing Job pod logs\n"
71 kubectl ${KUBECONFIG} logs $podName
73 #printf "\n\nBeginning E2E Remote VM Test Teardown\n\n"
75 kubectl ${KUBECONFIG} delete -f bpa_remote_virtletvm_cr.yaml
76 kubectl ${KUBECONFIG} delete job kud-remotevvm
77 kubectl ${KUBECONFIG} delete configmap remotevvm-configmap
78 kubectl ${KUBECONFIG} delete -f bpa_remote_virtletvm.yaml