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