Upgrade ironic and baremetal-operator components
[icn.git] / deploy / baremetal-operator / baremetal-operator.sh
1 #!/usr/bin/env bash
2 set -eux -o pipefail
3
4 SCRIPTDIR="$(readlink -f $(dirname ${BASH_SOURCE[0]}))"
5 LIBDIR="$(dirname $(dirname ${SCRIPTDIR}))/env/lib"
6
7 source $LIBDIR/logging.sh
8 source $LIBDIR/common.sh
9
10 # This may be used to update the in-place Bare Metal Operator YAML
11 # files from the upstream project
12 function build_source {
13     clone_baremetal_operator_repository
14     KUSTOMIZATION_FILES=$(find ${BMOPATH}/config/kustomization.yaml ${BMOPATH}/config/{namespace,default,crd,rbac,manager,webhook,certmanager} -type f)
15     for src in ${KUSTOMIZATION_FILES}; do
16         dst=${src/${BMOPATH}\/config/${SCRIPTDIR}\/base}
17         mkdir -p $(dirname ${dst})
18         cp ${src} ${dst}
19     done
20 }
21
22 function deploy {
23     kustomize build ${SCRIPTDIR}/icn | kubectl apply -f -
24     kubectl wait --for=condition=Available --timeout=600s deployment/baremetal-operator-controller-manager -n baremetal-operator-system
25 }
26
27 function clean {
28     kustomize build ${SCRIPTDIR}/icn | kubectl delete -f -
29 }
30
31 case $1 in
32     "build-source") build_source ;;
33     "clean") clean ;;
34     "deploy") deploy ;;
35     *) cat <<EOF
36 Usage: $(basename $0) COMMAND
37
38 Commands:
39   build-source  - Rebuild the in-tree Bare Metal Operator YAML files
40   clean         - Remove the Bare Metal Operator
41   deploy        - Deploy the Bare Metal Operator
42 EOF
43        ;;
44 esac