Update documentation for Cluster-API and Flux
[icn.git] / deploy / baremetal-operator / baremetal-operator.sh
1 #!/usr/bin/env bash
2 set -eEux -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 trap err_exit ERR
11 function err_exit {
12     kubectl get all -n baremetal-operator-system
13 }
14
15 # This may be used to update the in-place Bare Metal Operator YAML
16 # files from the upstream project
17 function build_source {
18     clone_baremetal_operator_repository
19     KUSTOMIZATION_FILES=$(find ${BMOPATH}/config/kustomization.yaml ${BMOPATH}/config/{namespace,default,crd,rbac,manager,webhook,certmanager} -type f)
20     for src in ${KUSTOMIZATION_FILES}; do
21         dst=${src/${BMOPATH}\/config/${SCRIPTDIR}\/base}
22         mkdir -p $(dirname ${dst})
23         cp ${src} ${dst}
24     done
25 }
26
27 function deploy {
28     kustomize build ${SCRIPTDIR}/icn | kubectl apply -f -
29     kubectl wait --for=condition=Available --timeout=600s deployment/baremetal-operator-controller-manager -n baremetal-operator-system
30 }
31
32 function clean {
33     kustomize build ${SCRIPTDIR}/icn | kubectl delete -f -
34 }
35
36 case $1 in
37     "build-source") build_source ;;
38     "clean") clean ;;
39     "deploy") deploy ;;
40     *) cat <<EOF
41 Usage: $(basename $0) COMMAND
42
43 Commands:
44   build-source  - Rebuild the in-tree Bare Metal Operator YAML files
45   clean         - Remove the Bare Metal Operator
46   deploy        - Deploy the Bare Metal Operator
47 EOF
48        ;;
49 esac