-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.sh
executable file
·48 lines (40 loc) · 1.34 KB
/
uninstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
set -euo pipefail
function installHelm() {
curl -sSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 -o helm-installer
bash helm-installer --version v3.12.2
}
function set_aws_creds() {
echo "Configuring aws cli."
local creds=(
"[herokles]"
"aws_access_key_id = $HEROKLES_AWS_ACCESS_KEY_ID"
"aws_secret_access_key = $HEROKLES_AWS_SECRET_ACCESS_KEY"
"region = $HEROKLES_AWS_REGION"
)
mkdir ~/.aws
printf '%s\n' "${creds[@]}" > ~/.aws/credentials
}
function main() {
[[ -d ~/.aws ]] || set_aws_creds
echo "Deleting environment variables."
if [[ ${FORCE_UNINSTALL:-} != true ]] && [[ $ENV != pr-${PR_NUM} ]] ; then
echo "ENV has to be a PR or FORCE_UNINSTALL=true must be set."
exit 1
fi
aws --profile herokles ssm delete-parameter --name /${PROJECT}/${ENV} || echo "Parameterer /${PROJECT}/${ENV} not found."
if [[ ! -d ~/.kube ]] && [[ -z ${KUBECONFIG:-} ]] ; then
echo "Setting up kubectl and heml"
installHelm
mkdir -p ~/.kube
echo "$HEROKLES_KUBECONFIG_BASE64" | base64 -d > ~/.kube/config
chmod 400 ~/.kube/config
fi
if [[ -f herokles/uninstall.sh ]] ; then
echo "Uninstall custom deployment"
else
echo "Uninstall Helm deployment"
helm uninstall -n ${PROJECT} ${PROJECT}-${ENV} --wait --timeout ${HEROKLES_HELM_TIMEOUT:-3m1s}
fi
}
main "$@"