Update versions of jump server components
[icn.git] / deploy / cert-manager / cert-manager.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     if command -v kubectl; then
13         kubectl get all -n cert-manager
14     fi
15 }
16
17 # This may be used to update the in-place cert-manager YAML
18 # files from the upstream project
19 function build_source {
20     mkdir -p ${SCRIPTDIR}/base
21     curl -sL https://github.com/jetstack/cert-manager/releases/download/${CERT_MANAGER_VERSION}/cert-manager.yaml -o ${SCRIPTDIR}/base/cert-manager.yaml
22     rm -f ${SCRIPTDIR}/base/kustomization.yaml
23     pushd ${SCRIPTDIR}/base && kustomize create --autodetect && popd
24 }
25
26 function deploy {
27     kustomize build ${SCRIPTDIR}/icn | kubectl apply -f -
28     kubectl -n cert-manager wait --for=condition=Available --timeout=300s deployment --all
29 }
30
31 function clean {
32     kustomize build ${SCRIPTDIR}/icn | kubectl delete -f -
33 }
34
35 case $1 in
36     "build-source") build_source ;;
37     "clean") clean ;;
38     "deploy") deploy ;;
39     *) cat <<EOF
40 Usage: $(basename $0) COMMAND
41
42 Commands:
43   build-source  - Rebuild the in-tree cert-manager YAML files
44   clean         - Remove the cert-manager
45   deploy        - Deploy the cert-manager
46 EOF
47        ;;
48 esac