Upgrade ironic and baremetal-operator components
[icn.git] / deploy / ironic / ironic.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 NAMEPREFIX="capm3"
11
12 # This may be used to update the in-place Ironic YAML files from the
13 # upstream project.  We cannot use the upstream sources directly as
14 # they require an envsubst step before kustomize build.
15 function build_source {
16     clone_baremetal_operator_repository
17     export NAMEPREFIX
18     KUSTOMIZATION_FILES=$(find ${BMOPATH}/ironic-deployment/{default,ironic} -type f)
19     for src in ${KUSTOMIZATION_FILES}; do
20         dst=${src/${BMOPATH}\/ironic-deployment/${SCRIPTDIR}\/base}
21         mkdir -p $(dirname ${dst})
22         envsubst <${src} >${dst}
23     done
24 }
25
26 function deploy {
27     fetch_image
28     kustomize build ${SCRIPTDIR}/icn | kubectl apply -f -
29     kubectl wait --for=condition=Available --timeout=600s deployment/${NAMEPREFIX}-ironic -n ${NAMEPREFIX}-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 Ironic YAML files
45   clean         - Remove Ironic
46   deploy        - Deploy Ironic
47 EOF
48        ;;
49 esac