Modify libvirt deploy to run from internal repo
[kni/installer.git] / ci / kni_deploy_libvirt.sh
1 #!/bin/bash
2 #
3 # Copyright (c) 2019 Red Hat
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #        http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 set -e -u -x -o pipefail
18
19 export PATH=$PATH:/usr/local/go/bin:/usr/local/bin
20 KNI_PATH='src/gerrit.akraino.org/kni/'
21 SITE_NAME='testing.virt.edge-sites.net'
22
23 echo '---> Starting kni installer generation'
24 export GOPATH=${WORKSPACE}/
25
26 # first build kni installer
27 sudo rm -rf ${WORKSPACE}/${KNI_PATH}
28 mkdir -p ${WORKSPACE}/${KNI_PATH}/installer
29 cp -a installer ${WORKSPACE}/${KNI_PATH}/
30 pushd ${WORKSPACE}/${KNI_PATH}/installer
31 make build 2>&1 | tee ${WORKSPACE}/build.log
32
33 # do a host preparation and cleanup
34 bash utils/prep_host.sh virt.edge-sites.net
35 wget https://raw.githubusercontent.com/openshift/installer/master/scripts/maintenance/virsh-cleanup.sh
36 chmod a+x ./virsh-cleanup.sh
37 sudo -E bash -c "yes Y | ./virsh-cleanup.sh"
38
39 # add the right credentials to kni
40 mkdir $HOME/.kni || true
41 cp $WORKSPACE/akraino-secrets/coreos-pull-secret $HOME/.kni/pull-secret.json || true
42 cp $HOME/.ssh/id_rsa.pub $HOME/.kni/id_rsa.pub || true
43
44 # start the workflow
45 sudo rm -rf /$HOME/.kni/${SITE_NAME}/final_manifests || true
46 ./knictl fetch_requirements file://${WORKSPACE}/blueprint-pae//sites/${SITE_NAME} 2>&1 | tee ${WORKSPACE}/libvirt_requirements.log
47 ./knictl prepare_manifests ${SITE_NAME} 2>&1 | tee ${WORKSPACE}/libvirt_manifests.log
48
49 # now run the cluster
50 source $HOME/.kni/${SITE_NAME}/profile.env
51 approve_certs &
52 FUNCTION_PID=$!
53 sudo -E $HOME/.kni/${SITE_NAME}/requirements/openshift-install create cluster --dir=/$HOME/.kni/${SITE_NAME}/final_manifests 2>&1 | tee ${WORKSPACE}/libvirt_deploy.log
54 STATUS=$?
55 kill $FUNCTION_PID || true
56
57 # output tfstate
58 echo "metadata.json for removing cluster"
59 cat $HOME/.kni/${SITE_NAME}/final_manifests/metadata.json
60
61 if [ $STATUS -ne 0 ]; then
62     echo "Error deploying in libvirt"
63     exit 1
64 fi
65
66 echo "Cluster successfully deployed! Start applying workloads"
67 ./knictl apply_workloads ${SITE_NAME} 2>&1 | tee ${WORKSPACE}/libvirt_workloads.log
68 STATUS=$?
69
70 if [ $STATUS -ne 0 ]; then
71     echo "Error applying workloads to libvirt"
72     exit 1
73 fi
74
75 popd
76 popd
77
78 exit $STATUS