argo1/uninstall.sh
James Andariese 8e8325a86e reliability improvements
fix some of the templating
make the uninstall script loop over all disableable apps and disable them
2023-04-23 23:22:46 -05:00

35 lines
815 B
Bash

#!/bin/bash
cd "$(dirname "$0")/argo1"
TARGETNS="argocd"
ORIGNS="$(kubectl config view --minify -o jsonpath='{..namespace}')"
all_subapps() {
(
for f in templates/*.yaml;do
sed -e '1!d' "$f"
done
) \
| grep -Eo '^#? *[{][{](- )? *if [(]index [.]Values "[^"]*"[)][.]enabled *( -)?[}][}]' \
| cut -d '"' -f 2
}
(
set -e
[ x"$TARGETNS" != x"$ORIGNS" ] && kubectl config set-context --current --namespace $TARGETNS
(
IFS=$'\n'
for app in $(all_subapps);do
argocd --core app set argo1 --helm-set "$app".enabled=false
done
)
sleep 10
argocd --core app wait --sync argo1
helm uninstall -n "$TARGETNS" argo1
bash delete-crds.sh
)
[ x"$TARGETNS" != x"$ORIGNS" ] && kubectl config set-context --current --namespace "$ORIGNS"