-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
238 lines (196 loc) Β· 7.4 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
# Makefile for local development
# Colors in echos: https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux
# Colors
BLACK=\033[0;30m
RED=\033[0;31m
GREEN=\033[0;32m
ORANGE=\033[0;33m
BLUE=\033[0;34m
PURPLE=\033[0;35m
CYAN=\033[0;36m
GRAY=\033[1;30m
# Light colors
WHITE=\033[1;37m
LRED=\033[1;31m
LGREEN=\033[1;32m
YELLOW=\033[1;33m
LBLUE=\033[1;34m
LPURPLE=\033[1;35m
LCYAN=\033[1;36m
LGRAY=\033[0;37m
# No color
NC=\033[0m
.ONESHELL: down
.PHONY: down clean help
# TAG to use for service image
# options: "dev" | "whatever"
# default: "dev"
export TAG := dev
# DAEMON to use containers. Either minikube daemon or regular local daemon
# options: "minikube" | "docker"
# default: "minikube"
export DAEMON := minikube
# IMG_SOURCE to get images from, either locally built or remotely pulled
# options: "local" | "remote"
# default: "local"
export IMG_SOURCE := local
# NAMESPACE for minikube instance to use.
# options: "default" | "whatever"
# default: "default"
export NAMESPACE := default
# SERVICE_NAME to use throughout. Changes deployment folder. Have to modify here too.
# options: "pods" | "whatever"
# default: "pods"
export SERVICE_NAME := pods
# SERVICE_PASS to use throughout. Must be filled.
export SERVICE_PASS := password
# TEST_ABACO_SERVICE_PASSWORD to use throughout. Must be filled for testing (it has ability to create tokens)
export TEST_ABACO_SERVICE_PASS := changeme
# STATIC_NFS_IP to use throughout. Must be filled.
export STATIC_NFS_IP := 10.96.175.175
# DEV_TOOLS bool. Whether or not to start jupyter + mount pods/service folder in pods (main).
# options: "false" | "true"
# default: "false"
export DEV_TOOLS := false
# Got from: https://stackoverflow.com/a/59087509
help:
@grep -B1 -E "^[a-zA-Z0-9_-]+\:([^\=]|$$)" Makefile \
| grep -v -- -- \
| sed 'N;s/\n/###/' \
| sed -n 's/^#: \(.*\)###\(.*\):.*/\2###\1/p' \
| column -t -s '###'
# Gets all remote images and starts pods in daemon mode
#: Deploy service
up: vars build
@echo "Makefile: $(GREEN)up$(NC)"
@echo " π : Looking to run ./burnup in deployment folder."
rm -rf deployment; mkdir deployment; cp -r deploymentTemplate/* deployment;
cd deployment
@echo " π¨ : Created deployment folder with templates."
@sed -i 's/"version".*/"version": "$(TAG)",/g' config.json
@sed -i 's/MAKEFILE_SERVICE_NAME/$(SERVICE_NAME)/g' *
@sed -i 's/MAKEFILE_SERVICE_PASS/$(SERVICE_PASS)/g' *
@sed -i 's/MAKEFILE_TEST_ABACO_SERVICE_PASS/$(TEST_ABACO_SERVICE_PASS)/g' *
@sed -i 's/MAKEFILE_STATIC_NFS_IP/$(STATIC_NFS_IP)/g' *
@sed -i 's/MAKEFILE_TAG/$(TAG)/g' *
@echo " π₯ : Running burnup."
ifeq ($(DEV_TOOLS),true)
@sed -i 's/#DEV//g' *
# Delete #DEV lines when DEV_TOOLS is set to false. Config can break b/c it has to be proper JSON.
else
@sed -i '/#DEV/d' *
@echo " π : Jupyter Lab URL: dev_tools is set to 'false'"
endif
@echo ""
./burnup
echo ""
ifeq ($(DEV_TOOLS),true)
@echo " π : Jupyter Lab URL: $(LCYAN)http://$$(minikube ip):$$(kubectl get service pods-api-jupyter | grep -o -P '(?<=8888:).*(?=/TCP)')$(NC)"
else
@echo " π : Jupyter Lab URL: dev_tools is set to 'false'"
endif
@echo " π : API URL: $(LCYAN)http://$$(minikube ip):$$(kubectl get service pods-traefik | grep -o -P '(?<= 80:)\d+(?=/TCP)')$(NC)/v3"
@echo " π : Docs URL: $(LCYAN)http://$$(minikube ip):$$(kubectl get service pods-api | grep -o -P '(?<=8000:)\d+(?=/TCP)')$(NC)/docs"
@echo " π : Spec URL: $(LCYAN)http://$$(minikube ip):$$(kubectl get service pods-api | grep -o -P '(?<=8000:)\d+(?=/TCP)')$(NC)/openapi.json"
@echo " π : Traefik Dash URL: $(LCYAN)http://$$(minikube ip):$$(kubectl get service pods-traefik | grep -o -P '(?<=8080:)\d+(?=/TCP)')$(NC)/dashboard"
@echo ""
#: Initialize a few templates
init-data:
@echo "Not yet implemented"
# Runs pytest in the pods-api container
#: Run tests in pods-api container
test:
@echo "Tests are a work in progress"
@echo "Makefile: $(GREEN)test$(NC)"
@echo " π : Running Tests"
@echo ""
kubectl exec -it deploy/pods-api -- pytest tests/*.py --disable-pytest-warnings
@echo ""
# Builds core locally and sets to correct tag. This should take priority over DockerHub images
#: Build core image
build: vars
@echo "Makefile: $(GREEN)build$(NC)"
@echo " π¨ : Running image build."
@echo " π : Using daemon: $(LCYAN)minikube$(NC)"
@echo " π : Building: This part takes a while if it takes a while."
@echo ""
minikube image build -t $(SERVICE_NAME)/pods-api:$$TAG ./
@echo ""
# Builds core locally with docker Daemon for publish/local-usage
#: Build core image in docker for publishing/develop
build-docker: vars
@echo "Makefile: $(GREEN)build$(NC)"
@echo " π¨ : Running image build."
@echo " π : Using daemon: $(LCYAN)docker$(NC)"
@echo ""
docker build -t tapis/pods-api:$$TAG ./
@echo ""
#: Pull core image
pull:
@echo "Makefile: $(GREEN)pull$(NC)"
@echo "Not yet implemented"
# Ends all active k8 containers needed for pods
#: Delete service
down:
@echo "Makefile: $(GREEN)down$(NC)"
@echo " π : Looking to run ./burndown in deployment folder."
if [ -d "deployment" ]; then
echo " π : Found deployment folder. Using burndown."
cd deployment
echo " π₯ : Running burndown."
echo ""
./burndown
else
echo " βοΈ : No deployment folder, nothing to burndown."
fi
@echo ""
# Cleans directory. Notably deletes the deployment folder if it exists
#: Delete service + folders
clean: down
@echo "Makefile: $(GREEN)clean$(NC)"
echo " π : Looking to delete deployment folder."
if [ -d "deployment" ]; then
rm -rf deployment
echo " π§Ή : Deployment folder deleted."
else
echo " βοΈ : Deployment folder already deleted."
fi
@echo ""
# Test setting of environment variables
#: Lists vars
vars:
@echo "Makefile: $(GREEN)vars$(NC)"
echo " βΉοΈ tag: $(LCYAN)$(TAG)$(NC)"
echo " βΉοΈ namespace: $(LCYAN)$(NAMESPACE)$(NC)"
echo " βΉοΈ service_name: $(LCYAN)$(SERVICE_NAME)$(NC)"
echo " βΉοΈ service_pass: $(LCYAN)$(SERVICE_PASS)$(NC)"
ifeq ($(filter $(DAEMON),minikube docker),)
echo " β daemon: $(RED)DAEMON must be one of ['minikube', 'docker']$(NC)"
exit 1
else
echo " βΉοΈ daemon: $(LCYAN)$(DAEMON)$(NC)"
endif
ifeq ($(filter $(IMG_SOURCE),local remote),)
echo " β img_source: $(RED)IMG_SOURCE must be one of ['local', 'remote']$(NC)"
exit 1
else
echo " βΉοΈ img_source: $(LCYAN)$(IMG_SOURCE)$(NC)"
endif
ifeq ($(filter $(DEV_TOOLS),true false),)
echo " β dev_tools: $(RED)DEV_TOOLS must be one of ['true', 'false']$(NC)"
exit 1
else
echo " βΉοΈ dev_tools: $(LCYAN)$(DEV_TOOLS)$(NC)"
endif
echo ""
ifeq ($(DEV_TOOLS),true)
@echo " π : Jupyter Lab URL: $(LCYAN)http://$$(minikube ip):$$(kubectl get service pods-api-jupyter | grep -o -P '(?<=8888:).*(?=/TCP)')$(NC)"
else
@echo " π : Jupyter Lab URL: dev_tools is set to 'false'"
endif
@echo " π : API URL: $(LCYAN)http://$$(minikube ip):$$(kubectl get service pods-traefik | grep -o -P '(?<= 80:)\d+(?=/TCP)')$(NC)/v3"
@echo " π : Docs URL: $(LCYAN)http://$$(minikube ip):$$(kubectl get service pods-api | grep -o -P '(?<=8000:)\d+(?=/TCP)')$(NC)/docs"
@echo " π : Spec URL: $(LCYAN)http://$$(minikube ip):$$(kubectl get service pods-api | grep -o -P '(?<=8000:)\d+(?=/TCP)')$(NC)/openapi.json"
@echo " π : Traefik Dash URL: $(LCYAN)http://$$(minikube ip):$$(kubectl get service pods-traefik | grep -o -P '(?<=8080:)\d+(?=/TCP)')$(NC)/dashboard"
@echo ""
echo ""