Merge "Add additional clean targets"
[icn.git] / deploy / cert-manager / cert-manager.sh
index ada4eb6..8983ce2 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/env bash
-set -eux -o pipefail
+set -eEux -o pipefail
 
 SCRIPTDIR="$(readlink -f $(dirname ${BASH_SOURCE[0]}))"
 LIBDIR="$(dirname $(dirname ${SCRIPTDIR}))/env/lib"
@@ -7,14 +7,19 @@ LIBDIR="$(dirname $(dirname ${SCRIPTDIR}))/env/lib"
 source $LIBDIR/logging.sh
 source $LIBDIR/common.sh
 
-# Cert-Manager version to use
-CERT_MANAGER_VERSION="v1.5.3"
+trap err_exit ERR
+function err_exit {
+    if command -v kubectl; then
+       kubectl get all -n cert-manager
+    fi
+}
 
 # This may be used to update the in-place cert-manager YAML
 # files from the upstream project
 function build_source {
     mkdir -p ${SCRIPTDIR}/base
     curl -sL https://github.com/jetstack/cert-manager/releases/download/${CERT_MANAGER_VERSION}/cert-manager.yaml -o ${SCRIPTDIR}/base/cert-manager.yaml
+    rm -f ${SCRIPTDIR}/base/kustomization.yaml
     pushd ${SCRIPTDIR}/base && kustomize create --autodetect && popd
 }
 
@@ -24,7 +29,7 @@ function deploy {
 }
 
 function clean {
-    kustomize build ${SCRIPTDIR}/icn | kubectl delete -f -
+    kustomize build ${SCRIPTDIR}/icn | kubectl delete --ignore-not-found=true -f -
 }
 
 case $1 in