-
Notifications
You must be signed in to change notification settings - Fork 0
/
aeto
executable file
·175 lines (145 loc) · 3.62 KB
/
aeto
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/usr/bin/env bash
declare resource_prefix="${AETO_RESOURCE_PREFIX:-tenant-}"
print() {
local all=false
[[ "${1:-}" == '--all' ]] && all=true
if [[ ${all:?} == true ]]; then
echo
echo 'ResourceTemplate'
kubectl get resourcetemplate -A -o wide
echo
echo 'Blueprint'
kubectl get blueprint -A -o wide
fi
echo
echo 'Tenant'
kubectl get tenant -A -o wide
echo
echo 'EventStreamChunk'
kubectl get eventstreamchunk -A -o wide
echo
echo 'ResourceSet'
kubectl get resourceset -A -o wide
if [[ ${all:?} == true ]]; then
echo
echo 'Namespaces'
kubectl get namespaces | grep "${resource_prefix:?}"
echo
echo 'NetworkPolicy'
kubectl get networkpolicy -A
echo
echo 'LimitRange'
kubectl get limitrange -A
fi
echo
echo 'AWS Route53 HostedZone'
kubectl get hostedzone -A -o wide
echo
echo 'AWS ACM Certificate'
kubectl get certificate -A -o wide
echo
echo 'AWS ACM CertificateConnector'
kubectl get certificateconnector -A -o wide
echo
echo 'Sustainability SavingsPolicy'
kubectl get savingspolicy -A -o wide
if [[ ${all:?} == true ]]; then
echo
echo 'Deployment'
kubectl get deployment -A | grep "${resource_prefix:?}"
echo
echo 'Service'
kubectl get service -A | grep "${resource_prefix:?}"
echo
echo 'Ingress'
kubectl get ingress -A | grep "${resource_prefix:?}"
fi
echo
}
events() {
echo
echo 'EventStreamChunks:'
kubectl -n aeto get eventstreamchunk -o wide
echo
echo 'Event summary:'
kubectl -n aeto get eventstreamchunk -o json | jq -r '.items[].spec.events[].raw' | jq -c -r .type
echo
echo 'Event details:'
kubectl -n aeto get eventstreamchunk -o json | jq -r '.items[].spec.events[].raw' | jq -c .
}
apply() {
kubectl apply -k config/default-resources/
kubectl apply -k config/samples/
echo 'watching Tenant and ResourceSets...'
# kubectl --namespace <namespace> tenant <name> wait --for=condition=ready -o name
sleep 1
while true; do
clear && print
sleep 3
done
}
destroy() {
kubectl delete -k config/samples/
print --all
echo 'Press any key to continue running a full cleanup...'
read -r
cleanup
}
cleanup() {
echo 'running a full cleanup'
kubectl delete -k config/default-resources/
# shellcheck disable=SC2046
kubectl -n aeto delete resourceset $(kubectl -n aeto get resourceset -o jsonpath='{.items[*].metadata.name}')
# shellcheck disable=SC2046
kubectl -n aeto delete eventstreamchunk $(kubectl -n aeto get eventstreamchunk -o jsonpath='{.items[*].metadata.name}')
kubectl delete namespace tenant-example
}
setup() {
echo 'setting up local environment for development'
echo
kind create cluster
make install
kubectl create namespace aeto
echo
echo 'done setting up development environment'
echo 'next up:'
echo ' - make run'
echo ' - ./aeto apply'
}
watch() {
while true; do
clear && print && sleep 3
done
}
localenv() {
{
sed "/AWS_REGION=.*/d" <.env |
sed "/AWS_ACCESS_KEY_ID=.*/d" |
sed "/AWS_SECRET_ACCESS_KEY=.*/d" |
sed "/AWS_SESSION_TOKEN=.*/d"
echo "AWS_REGION=${AWS_REGION:?}"
echo "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:?}"
echo "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:?}"
echo "AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN:?}"
} >.tempenv
mv .tempenv .env
}
release() {
make manifests
make generate
goreleaser release --rm-dist
}
main() {
case "${1:-}" in
localenv) localenv ;;
apply) apply ;;
destroy) destroy ;;
cleanup) cleanup ;;
watch) watch ;;
events) events ;;
release) release ;;
setup) setup ;;
*) print --all ;;
esac
}
main "$@"