3 # Copyright (c) 2019 Red Hat
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 set -e -u -x -o pipefail
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'
23 echo '---> Starting kni installer generation'
24 export GOPATH=${WORKSPACE}/
26 function approve_certs() {
27 # sleep for the first 10 min
30 # temporary fix, autoapprove certificates on background
32 export KUBECONFIG=$HOME/.kni/${SITE_NAME}/final_manifests/auth/kubeconfig
33 oc get csr | grep worker | grep Pending | awk '{print $1}' | xargs -n 1 oc adm certificate approve || true
38 # move the blueprint to an inner directory
39 mkdir ${WORKSPACE}/blueprint-pae
40 mv base profiles sites tools ${WORKSPACE}/blueprint-pae/
42 # clone installer in the right directory
43 sudo rm -rf ${WORKSPACE}/${KNI_PATH}
44 mkdir -p ${WORKSPACE}/${KNI_PATH}
45 pushd ${WORKSPACE}/${KNI_PATH}/
46 git clone https://gerrit.akraino.org/r/kni/installer
49 # first build kni installer
50 make build 2>&1 | tee ${WORKSPACE}/build.log
52 # do a host preparation and cleanup
53 bash utils/prep_host.sh virt.edge-sites.net
54 wget https://raw.githubusercontent.com/openshift/installer/master/scripts/maintenance/virsh-cleanup.sh
55 chmod a+x ./virsh-cleanup.sh
56 sudo -E bash -c "yes Y | ./virsh-cleanup.sh"
58 # add the right credentials to kni
59 mkdir $HOME/.kni || true
60 cp $WORKSPACE/akraino-secrets/coreos-pull-secret $HOME/.kni/pull-secret.json || true
61 cp $HOME/.ssh/id_rsa.pub $HOME/.kni/id_rsa.pub || true
64 sudo rm -rf /$HOME/.kni/${SITE_NAME}/final_manifests || true
65 ./knictl fetch_requirements file://${WORKSPACE}/blueprint-pae//sites/${SITE_NAME} 2>&1 | tee ${WORKSPACE}/libvirt_requirements.log
66 ./knictl prepare_manifests ${SITE_NAME} 2>&1 | tee ${WORKSPACE}/libvirt_manifests.log
69 source $HOME/.kni/${SITE_NAME}/profile.env
72 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
74 kill $FUNCTION_PID || true
77 echo "metadata.json for removing cluster"
78 cat $HOME/.kni/${SITE_NAME}/final_manifests/metadata.json
80 if [ $STATUS -ne 0 ]; then
81 echo "Error deploying in libvirt"
85 echo "Cluster successfully deployed! Start applying workloads"
86 ./knictl apply_workloads ${SITE_NAME} 2>&1 | tee ${WORKSPACE}/libvirt_workloads.log
89 if [ $STATUS -ne 0 ]; then
90 echo "Error applying workloads to libvirt"