Update documentation for Cluster-API and Flux
[icn.git] / deploy / ironic / ironic.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 NAMEPREFIX="capm3"
11
12 trap err_exit ERR
13 function err_exit {
14     kubectl get all -n ${NAMEPREFIX}-system
15 }
16
17 # This may be used to update the in-place Ironic YAML files from the
18 # upstream project.  We cannot use the upstream sources directly as
19 # they require an envsubst step before kustomize build.
20 function build_source {
21     clone_baremetal_operator_repository
22     export NAMEPREFIX
23     KUSTOMIZATION_FILES=$(find ${BMOPATH}/ironic-deployment/{default,ironic} -type f)
24     for src in ${KUSTOMIZATION_FILES}; do
25         dst=${src/${BMOPATH}\/ironic-deployment/${SCRIPTDIR}\/base}
26         mkdir -p $(dirname ${dst})
27         envsubst <${src} >${dst}
28     done
29     sed -i -e '/name: quay.io\/metal3-io\/ironic/{n;s/newTag:.*/newTag: '"${BMO_VERSION}"'/;}' ${SCRIPTDIR}/icn/kustomization.yaml
30 }
31
32 function deploy {
33     fetch_image
34     kustomize build ${SCRIPTDIR}/icn | kubectl apply -f -
35     kubectl wait --for=condition=Available --timeout=600s deployment/${NAMEPREFIX}-ironic -n ${NAMEPREFIX}-system
36 }
37
38 function clean {
39     kustomize build ${SCRIPTDIR}/icn | kubectl delete -f -
40 }
41
42 case $1 in
43     "build-source") build_source ;;
44     "clean") clean ;;
45     "deploy") deploy ;;
46     *) cat <<EOF
47 Usage: $(basename $0) COMMAND
48
49 Commands:
50   build-source  - Rebuild the in-tree Ironic YAML files
51   clean         - Remove Ironic
52   deploy        - Deploy Ironic
53 EOF
54        ;;
55 esac