argo1/uninstall.sh

35 lines
815 B
Bash
Raw Permalink Normal View History

2023-04-24 02:05:13 +00:00
#!/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
}
2023-04-24 02:05:13 +00:00
(
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
2023-04-24 02:05:13 +00:00
helm uninstall -n "$TARGETNS" argo1
bash delete-crds.sh
)
[ x"$TARGETNS" != x"$ORIGNS" ] && kubectl config set-context --current --namespace "$ORIGNS"