forked from vfarcic/idp-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdestroy.sh
executable file
·109 lines (76 loc) · 2.98 KB
/
destroy.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/sh
gum style \
--foreground 212 --border-foreground 212 --border double \
--margin "1 2" --padding "2 4" \
'Destroy all the resources created for the
"How To Create A Complete Internal Developer Platform (IDP)?"
video.'
gum confirm '
Are you ready to start?
Feel free to say "No" and inspect the script if you prefer destroying resources manually.
' || exit 0
################
# Requirements #
################
echo "You will need following tools installed:"
echo "
|Name |Required |More info |
|----------------|---------------------|---------------------------------------------------|
|Charm Gum |Yes |'https://github.com/charmbracelet/gum#installation'|
|gitHub CLi |Yes |'https://youtu.be/BII6ZY2Rnlc' |
|Google Cloud CLI|If using Google Cloud|'https://cloud.google.com/sdk/docs/install' |
|AWS CLI |If using AWS |'https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html'|
|eksctl |If using AWS |'https://eksctl.io/introduction/#installation' |
" | gum format
gum confirm "
Do you have those tools installed?
" || exit 0
###########
# Destroy #
###########
source .env
cd idp-demo
git pull
rm -rf infra/*.yaml apps/*.yaml
git add .
git commit -m "Destroy"
git push
if [[ "$HYPERSCALER" == "google" ]]; then
gcloud projects delete $PROJECT_ID
rm -f account.json gcp-creds.json gke_gcloud_auth_plugin_cache
elif [[ "$HYPERSCALER" == "aws" ]]; then
gum style \
--foreground 212 --border-foreground 212 --border double \
--margin "1 2" --padding "2 4" \
"We need to wait until all the resources in $HYPERSCALER are destroyed." \
"
It might take a while..."
COUNTER=$(kubectl get aws | grep -v NAME | grep -v providerconfig | wc -l)
while [ $COUNTER -ne 0 ]; do
sleep 10
COUNTER=$(kubectl get aws | grep -v NAME | grep -v providerconfig | wc -l)
done
eksctl delete addon --name aws-ebs-csi-driver --cluster dot
eksctl delete cluster --config-file eksctl-config.yaml
rm -f aws-creds.conf
fi
gh repo view $GITHUB_ORG/idp-demo-app --web
echo '
Open "Settings" followed by "Delete this repository" and follow
the instructions to remove the forked repository.
If the repo did not open in a browser and you got the
"Could not resolve to a Repository" message, the repo was
probably not created in the first place and you can ignore
this step and press the enter key to continue.'
gum input --placeholder "
Press the enter key to continue."
gh repo view $GITHUB_ORG/idp-demo --web
echo "
Open \"Settings\" followed by \"Delete this repository\" and follow the instructions to remove the forked repository."
gum input --placeholder "
Press the enter key to continue."
echo "
Delete all entities and blueprints from Port."
gum input --placeholder "
Press the enter key to continue."
rm -rf idp-demo idp-demo-app kubeconfig.yaml .env