This repository has been archived by the owner on Sep 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
239 lines (189 loc) · 8.09 KB
/
Makefile
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
.PHONY: help all create delete deploy check clean rrapi rrui rrprod ngsa lr reset-prometheus reset-grafana jumpbox
help :
@echo "Usage:"
@echo " make all - create a cluster and deploy the apps"
@echo " make create - create a kind cluster"
@echo " make delete - delete the kind cluster"
@echo " make deploy - deploy the apps to the cluster"
@echo " make check - curl endpoints cluster"
@echo " make clean - delete deployments"
@echo " make beta - deploy all loderunner images from registry"
@echo " make lrapi - build and deploy a local loderunner-api docker image"
@echo " make lrui - build and deploy a local loderunner-client docker image"
@echo " make ngsa - build and deploy a local ngsa-app docker image"
@echo " make lr - build and deploy a local loderunner docker image"
@echo " make reset-prometheus - reset the Prometheus volume (existing data is deleted)"
@echo " make reset-grafana - reset the Grafana volume (existing data is deleted)"
@echo " make jumpbox - deploy a 'jumpbox' pod"
all : create deploy jumpbox check
delete :
# delete the cluster (if exists)
@# this will fail harmlessly if the cluster does not exist
-k3d cluster delete
create : delete
# create the cluster and wait for ready
@# this will fail harmlessly if the cluster exists
@# default cluster name is k3d
@k3d cluster create --registry-use k3d-registry.localhost:5000 --config deploy/k3d.yaml --k3s-server-arg "--no-deploy=traefik" --k3s-server-arg "--no-deploy=servicelb"
# wait for cluster to be ready
@kubectl wait node --for condition=ready --all --timeout=60s
@sleep 5
@kubectl wait pod -A --all --for condition=ready --timeout=60s
deploy :
# deploy ngsa-app
@# continue on most errors
-kubectl apply -f deploy/ngsa-memory
# deploy loderunner after the ngsa-app starts
@kubectl wait pod ngsa-memory --for condition=ready --timeout=30s
-kubectl apply -f deploy/loderunner-local
# Create backend image from codebase
@docker build ./backend -t k3d-registry.localhost:5000/loderunner-api:local
# Load new backend image to k3d registry
@docker push k3d-registry.localhost:5000/loderunner-api:local
# deploy local relayrunner backend
-kubectl apply -f deploy/loderunner-api/local
# Create client image from codebase
@docker build ./client --target nginx-dev -t k3d-registry.localhost:5000/loderunner-ui:local
# Load new client image to k3d registry
@docker push k3d-registry.localhost:5000/loderunner-ui:local
# deploy local relayrunner client
-kubectl apply -f deploy/loderunner-ui:local
# deploy prometheus and grafana
-kubectl apply -f deploy/prometheus
-kubectl apply -f deploy/grafana
# deploy fluentbit
-kubectl create secret generic log-secrets --from-literal=WorkspaceId=dev --from-literal=SharedKey=dev
-kubectl apply -f deploy/fluentbit/account.yaml
-kubectl apply -f deploy/fluentbit/log.yaml
-kubectl apply -f deploy/fluentbit/stdout-config.yaml
-kubectl apply -f deploy/fluentbit/fluentbit-pod.yaml
# wait for pods to start
@kubectl wait pod -A --all --for condition=ready --timeout=60s
# display pod status
-kubectl get po -A | grep "default\|monitoring"
check :
# curl all of the endpoints
@echo "\nchecking ngsa-memory..."
@curl localhost:30080/version
@echo "\n\nchecking loderunner..."
@curl localhost:30088/version
@echo "\n\nchecking prometheus..."
@curl localhost:30000
@echo "\nchecking grafana..."
@curl localhost:32000
@echo "\nchecking loderunner ui..."
@curl localhost:32080
@echo "\n\nchecking loderunner api..."
@curl localhost:32088/version
clean :
# delete the deployment
@# continue on error
-kubectl delete -f deploy/loderunner-local --ignore-not-found=true
-kubectl delete -f deploy/ngsa-memory --ignore-not-found=true
-kubectl delete ns monitoring --ignore-not-found=true
-kubectl delete -f deploy/fluentbit/fluentbit-pod.yaml --ignore-not-found=true
-kubectl delete -f deploy/loderunner-ui/local --ignore-not-found=true
-kubectl delete -f deploy/loderunner-api/local --ignore-not-found=true
-kubectl delete secret log-secrets --ignore-not-found=true
# show running pods
@kubectl get po -A
beta:
# delete local backend pod and deploy image from ghcr
-kubectl delete -f deploy/loderunner-api/local --ignore-not-found=true
kubectl apply -f deploy/loderunner-api
# wait for pod to be ready
@sleep 5
@kubectl wait pod loderunner-api --for condition=ready --timeout=30s
# delete local client pod and deploy image from ghcr
-kubectl delete -f deploy/loderunner-ui/local --ignore-not-found=true
kubectl apply -f deploy/loderunner-ui
# wait for pod to be ready
@sleep 5
@kubectl wait pod loderunner-ui --for condition=ready --timeout=30s
# delete local loderunner pod and deploy image from ghcr
-kubectl delete -f deploy/loderunner-local --ignore-not-found=true
kubectl apply -f deploy/loderunner
# wait for pod to be ready
@sleep 5
@kubectl wait pod loderunner --for condition=ready --timeout=30s
@kubectl get po
# display the loderunner version
-http localhost:30088/version
# display the backend version
-http localhost:32088/version
# hit the client endpoint
-http -h localhost:32080
lrapi:
# build the local image and load into k3d
docker build ./backend -t k3d-registry.localhost:5000/loderunner-api:local
docker push k3d-registry.localhost:5000/loderunner-api:local
# delete/deploy the local backend
-kubectl delete -f deploy/loderunner-api/local --ignore-not-found=true
kubectl apply -f deploy/loderunner-api/local
# wait for pod to be ready
@sleep 5
@kubectl wait pod loderunner-api --for condition=ready --timeout=30s
@kubectl get po
# display the version
-http localhost:32088/version
lrui:
# build the local image and load into k3d
docker build ./client --target nginx-dev -t k3d-registry.localhost:5000/loderunner-ui:local
docker push k3d-registry.localhost:5000/loderunner-ui:local
# delete/deploy local client
-kubectl delete -f deploy/loderunner-ui/local --ignore-not-found=true
kubectl apply -f deploy/loderunner-ui/local
# wait for pod to be ready
@sleep 5
@kubectl wait pod loderunner-ui --for condition=ready --timeout=30s
@kubectl get po
# hit the client endpoint
-http -h localhost:32080
ngsa :
# build the local image of ngsa-app and load into k3d
docker build ../ngsa-app -t k3d-registry.localhost:5000/ngsa-app:local
docker push k3d-registry.localhost:5000/ngsa-app:local
# delete loderunner
-kubectl delete -f deploy/loderunner --ignore-not-found=true
# delete/deploy the ngsa-app
-kubectl delete -f deploy/ngsa-memory --ignore-not-found=true
kubectl apply -f deploy/ngsa-local
# deploy loderunner after app starts
@kubectl wait pod ngsa-memory --for condition=ready --timeout=30s
@sleep 5
kubectl apply -f deploy/loderunner
@kubectl wait pod loderunner --for condition=ready --timeout=30s
@kubectl get po
# display the ngsa-app version
-http localhost:30080/version
lr :
# build the local image of loderunner and load into k3d
docker build ../loderunner -t k3d-registry.localhost:5000/ngsa-lr:local
docker push k3d-registry.localhost:5000/ngsa-lr:local
# delete / create loderunner
-kubectl delete -f deploy/loderunner --ignore-not-found=true
kubectl apply -f deploy/loderunner-local
kubectl wait pod loderunner --for condition=ready --timeout=30s
@kubectl get po
# display the current version
-http localhost:30088/version
reset-prometheus :
# remove and create the /prometheus volume
@sudo rm -rf /prometheus
@sudo mkdir -p /prometheus
@sudo chown -R 65534:65534 /prometheus
reset-grafana :
# remove and copy the data to /grafana volume
@sudo rm -rf /grafana
@sudo mkdir -p /grafana
@sudo cp -R deploy/grafanadata/grafana.db /grafana
@sudo chown -R 472:472 /grafana
jumpbox :
# start a jumpbox pod
@-kubectl delete pod jumpbox --ignore-not-found=true
@kubectl run jumpbox --image=ghcr.io/retaildevcrews/alpine --restart=Always -- /bin/sh -c "trap : TERM INT; sleep 9999999999d & wait"
@kubectl wait pod jumpbox --for condition=ready --timeout=30s
# Run an interactive bash shell in the jumpbox
# kj
# use kje <command>
# kje http ngsa-memory:8080/version