This repository has been archived by the owner on Sep 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathMakefile
156 lines (124 loc) · 5.7 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
.PHONY: help all create delete deploy check clean app webv test load-test jumpbox
help :
@echo "Usage:"
@echo " make all - create a cluster and deploy the apps"
@echo " make create - create a k3d cluster"
@echo " make delete - delete the k3d cluster"
@echo " make deploy - deploy the apps to the cluster"
@echo " make check - check the endpoints with curl"
@echo " make test - run a WebValidate test"
@echo " make load-test - run a 60 second WebValidate test"
@echo " make clean - delete the apps from the cluster"
@echo " make app - build and deploy a local app docker image"
@echo " make webv - build and deploy a local WebV docker image"
@echo " make jumpbox - deploy a 'jumpbox' pod"
all : create deploy jumpbox
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:5500 --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 the app
@# continue on most errors
@kubectl apply -f deploy/ngsa-memory
# deploy prometheus and grafana
@kubectl apply -f deploy/prometheus
@kubectl apply -f deploy/grafana
# deploy fluent bit
@kubectl create secret generic log-secrets --from-literal=WorkspaceId=dev --from-literal=SharedKey=dev
@kubectl apply -f deploy/fluentbit
# wait for the pods to start
@kubectl wait pod -n monitoring --for condition=ready --all --timeout=30s
@kubectl wait pod -n logging fluentbit --for condition=ready --timeout=30s
# deploy WebV after the app starts
@kubectl wait pod ngsa-memory --for condition=ready --timeout=30s
@kubectl apply -f deploy/webv
@kubectl wait pod webv --for condition=ready --timeout=30s
# display pod status
@kubectl get po -A | grep "default\|monitoring\|logging"
check :
# curl all of the endpoints
@curl localhost:30080/version
@echo "\n"
@curl localhost:30088/version
@echo "\n"
@curl localhost:30000
@curl localhost:32000
clean :
# delete the deployment
@# continue on error
-kubectl delete pod jumpbox --ignore-not-found=true
-kubectl delete -f deploy/webv --ignore-not-found=true
-kubectl delete -f deploy/ngsa-memory --ignore-not-found=true
-kubectl delete ns monitoring --ignore-not-found=true
-kubectl delete ns logging --ignore-not-found=true
# show running pods
@kubectl get po -A
app :
# build push the local image
docker build ../ngsa-app -t k3d-registry.localhost:5500/ngsa-app:local
docker push k3d-registry.localhost:5500/ngsa-app:local
# delete WebV
-kubectl delete -f deploy/webv --ignore-not-found=true
# delete/deploy the app
-kubectl delete -f deploy/ngsa-memory --ignore-not-found=true
kubectl apply -f deploy/ngsa-local
# deploy WebValidate after app starts
@kubectl wait pod ngsa-memory --for condition=ready --timeout=30s
kubectl apply -f deploy/webv
@kubectl wait pod webv --for condition=ready --timeout=30s
@kubectl get po
# display the app version
-http localhost:30080/version
webv :
# build and push the local image
docker build ../webvalidate -t k3d-registry.localhost:5500/webv:local
docker push k3d-registry.localhost:5500/webv:local
# delete / create WebValidate
-kubectl delete -f deploy/webv --ignore-not-found=true
kubectl apply -f deploy/webv-local
kubectl wait pod webv --for condition=ready --timeout=30s
@kubectl get po
# display the current version
-http localhost:30088/version
test :
# use WebValidate to run a test
webv --verbose --summary tsv --server http://localhost:30080 --files baseline.json
# the 400 and 404 results are expected
# Errors and ValidationErrorCount should both be 0
load-test :
# use WebValidate to run a 60 second test
webv --verbose --server http://localhost:30080 --files benchmark.json --run-loop --sleep 100 --duration 60
jumpbox :
# start a jumpbox pod
@-kubectl delete pod jumpbox --ignore-not-found=true
@kubectl run jumpbox --image=ghcr.io/cse-labs/jumpbox --restart=Always -- /bin/sh -c "trap : TERM INT; sleep 9999999999d & wait"
@kubectl wait pod jumpbox --for condition=ready --timeout=30s
###### If you get an error after this ####
# run make patch-jumpbox
@kubectl exec jumpbox -- /bin/sh -c "apk update && apk add bash curl nano jq py-pip" > /dev/null
@kubectl exec jumpbox -- /bin/sh -c "pip3 install --upgrade pip setuptools httpie" > /dev/null
@kubectl exec jumpbox -- /bin/sh -c "echo \"alias ls='ls --color=auto'\" >> /root/.profile && echo \"alias ll='ls -lF'\" >> /root/.profile && echo \"alias la='ls -alF'\" >> /root/.profile && echo 'cd /root' >> /root/.profile" > /dev/null
# Run an interactive bash shell in the jumpbox
# kj
# use kje <command>
# kje http ngsa-memory:8080/version
patch-jumpbox :
@# in case of ddos
@kubectl wait pod jumpbox --for condition=ready --timeout=30s
@kubectl exec jumpbox -- /bin/sh -c "apk update && apk add bash curl nano jq py-pip" > /dev/null
@kubectl exec jumpbox -- /bin/sh -c "pip3 install --upgrade pip setuptools httpie" > /dev/null
@kubectl exec jumpbox -- /bin/sh -c "echo \"alias ls='ls --color=auto'\" >> /root/.profile && echo \"alias ll='ls -lF'\" >> /root/.profile && echo \"alias la='ls -alF'\" >> /root/.profile && echo 'cd /root' >> /root/.profile" > /dev/null
# Run an interactive bash shell in the jumpbox
# kj
# use kje <command>
# kje http ngsa-memory:8080/version