forked from cse-labs/kubernetes-in-codespaces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
163 lines (130 loc) · 5.71 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
.PHONY: help all create delete deploy check clean app webv test load-test 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 - 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 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 : delete create deploy jumpbox
delete :
# delete the cluster (if exists)
@# this will fail harmlessly if the cluster does not exist
@kind delete cluster
create :
# create the cluster and wait for ready
@# this will fail harmlessly if the cluster exists
@# default cluster name is kind
@kind create cluster --config deploy/kind/kind.yaml
# wait for cluster to be ready
@kubectl wait node --for condition=ready --all --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/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
# deploy WebV after the app starts
@kubectl wait pod ngsa-memory --for condition=ready --timeout=30s
-kubectl apply -f deploy/webv
# wait for the pods to start
@kubectl wait pod -n monitoring --for condition=ready --all --timeout=30s
@kubectl wait pod fluentb --for condition=ready --timeout=30s
@kubectl wait pod webv --for condition=ready --timeout=30s
# display pod status
@kubectl get po -A | grep "default\|monitoring"
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 -f deploy/fluentbit/fluentbit-pod.yaml --ignore-not-found=true
-kubectl delete secret log-secrets --ignore-not-found=true
# show running pods
@kubectl get po -A
app :
# build the local image and load into kind
docker build ../ngsa-app -t ngsa-app:local
kind load docker-image 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
@sleep 5
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 the local image and load into kind
docker build ../webvalidate -t webv:local
kind load docker-image 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 --server http://localhost:30080 --files webv/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 webv/benchmark.json --run-loop --sleep 100 --duration 60
reset-prometheus :
# remove and create the /prometheus volume
-kubectl delete -f deploy/prometheus/3-prometheus-deployment.yaml
@sudo rm -rf /prometheus/wal
@sudo chown -R 65534:65534 /prometheus
# redeploy Prometheus - kubectl apply -f deploy/prometheus
reset-grafana :
# remove and copy the data to /grafana volume
-kubectl delete -f deploy/grafana/deployment.yaml
@sudo rm -f /grafana/grafana.db
@sudo cp -R deploy/grafanadata/grafana.db /grafana
@sudo chown -R 472:472 /grafana
# redeploy Grafana - kubectl apply -f deploy/grafana
jumpbox :
@# start a jumpbox pod
@-kubectl delete pod jumpbox --ignore-not-found=true
@kubectl run jumpbox --image=alpine --restart=Always -- /bin/sh -c "trap : TERM INT; sleep 9999999999d & wait"
@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