-
Notifications
You must be signed in to change notification settings - Fork 16
/
ee-k10-destroy.sh
executable file
·42 lines (32 loc) · 2.04 KB
/
ee-k10-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
starttime=$(date +%s)
. ./setenv.sh
clusterid=$(kubectl get namespace default -ojsonpath="{.metadata.uid}{'\n'}")
# eksctl delete cluster --name $(cat k10_eks_clustername) --region $MY_REGION
# aws iam get-role --role-name k10-iam-role4yong1 | grep role4yong1
echo '-------Deleting AWS IAM role and policy'
aws iam delete-role-policy --role-name k10-iam-role4yong1 --policy-name k10-iam-policy4yong1
aws iam delete-role --role-name k10-iam-role4yong1
echo '-------Deleting Cassandra and Kasten K10'
helm uninstall cassandra -n k10-cassandra
helm uninstall k10 -n kasten-io
kubectl delete ns k10-cassandra
kubectl delete ns kasten-io
# echo '-------Deleting EBS Volumes'
# aws ec2 describe-volumes --region $MY_REGION --query "Volumes[*].{ID:VolumeId}" --filters Name=tag:eks:cluster-name,Values=$(cat k10_eks_clustername) | grep ID | awk '{print $2}' > ebs.list
# aws ec2 describe-volumes --region $MY_REGION --query "Volumes[*].{ID:VolumeId}" --filters Name=tag:kubernetes.io/cluster/$(cat k10_eks_clustername),Values=owned | grep ID | awk '{print $2}' >> ebs.list
# for i in $(sed 's/\"//g' ebs.list);do echo $i;aws ec2 delete-volume --volume-id $i;done
echo '-------Deleting snapshots'
aws ec2 describe-snapshots --owner self --query "Snapshots[*].{ID:SnapshotId}" --filters Name=tag:kanister.io/clustername,Values=$clusterid --region $MY_REGION | grep ID | awk '{print $2}' > ebssnap.list
for i in $(sed 's/\"//g' ebssnap.list);do echo $i;aws ec2 delete-snapshot --snapshot-id $i;done
echo '-------Deleting objects from the bucket'
aws s3 rb s3://$(cat k10_eks_bucketname) --force
# echo '-------Deleting kubeconfig for this cluster'
# kubectl config delete-context $(kubectl config get-contexts | grep $(cat k10_eks_clustername) | awk '{print $2}')
echo "" | awk '{print $1}'
endtime=$(date +%s)
duration=$(( $endtime - $starttime ))
echo "-------Total time is $(($duration / 60)) minutes $(($duration % 60)) seconds."
echo "" | awk '{print $1}'
echo "-------Created by Yongkang"
echo "-------Email me if any suggestions or issues he@yongkang.cloud"
echo "" | awk '{print $1}'