-
Notifications
You must be signed in to change notification settings - Fork 3
/
eks.sh
executable file
·70 lines (59 loc) · 1.5 KB
/
eks.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
#!/bin/bash
fatal() { echo -e "ERROR: $@" 1>&2; exit 1; }
downloadPass() {
kubectl -n kube-system describe secret "$(kubectl -n kube-system get secret | grep eks-admin | awk '{print $1}')" > /dev/null 2>&1
}
installServices() {
if [ "$(ls services)" ]
then
kubectl apply -R -f services/ > /dev/null
fi
}
installIngresses() {
if [ "$(ls ingresses)" ]
then
kubectl apply -R -f ingresses/ > /dev/null
fi
}
installSecrets() {
if [ "$(ls secrets)" ]
then
kubectl apply -R -f secrets/ > /dev/null
fi
}
removeServices() {
if [ "$(ls services)" ]
then
kubectl delete -f services/ > /dev/null
fi
}
removeIngresses() {
if [ "$(ls ingresses)" ]
then
kubectl delete -R -f ingresses/ > /dev/null
fi
}
removeSecrets() {
if [ "$(ls secrets)" ]
then
kubectl delete -R -f secrets/ > /dev/null
fi
}
exportCfg() {
aws eks update-kubeconfig --name $K8S_CLUSTER_NAME
}
#FIRST: check sanity
kubectl >/dev/null || fatal 'The `kubectl` CLI tool is not available.'
aws --version > /dev/null 2>&1 || fatal 'The `aws` CLI tool is not available.'
case "$1" in
config) exportCfg ;;
removeServices) removeServices ;;
removeIngresses) removeIngresses ;;
removeSecrets) removeSecrets ;;
installServices) installServices ;;
installIngresses) installIngresses ;;
installSecrets) installSecrets ;;
*) echo -e "usage: $0 removeServices | removeIngresses | removeSecrets | installServices | installIngresses | installSecrets | config" >&2
exit 1
;;
esac