-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovision.mk
100 lines (78 loc) · 3.63 KB
/
provision.mk
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
LLMA_REPO ?= https://github.com/llmariner/llmariner.git
CLONE_PATH ?= work
TN_CLUSTER ?= job-tn
CP_CLUSTER ?= job-cp
WP_CLUSTER ?= job-wp
WORKER_NUM ?= 1
# ------------------------------------------------------------------------------
# chart repository
# ------------------------------------------------------------------------------
.PHONY: pull-llma-chart
pull-llma-chart:
@if [ -d $(CLONE_PATH) ]; then \
cd $(CLONE_PATH) && \
git checkout -- deployments/llmariner/Chart.yaml && \
git pull; \
else \
git clone $(LLMA_REPO) $(CLONE_PATH); \
fi
.PHONY: configure-llma-chart
configure-llma-chart:
hack/overwrite-llma-chart-for-test.sh $(CLONE_PATH)
-rm $(CLONE_PATH)/deployments/llmariner/Chart.lock
# ------------------------------------------------------------------------------
# kind cluster
# ------------------------------------------------------------------------------
.PHONY: create-kind-cluster
create-kind-cluster:
hack/create-kind-cluster.sh "$(TN_CLUSTER)" "$(CP_CLUSTER)" "$(WP_CLUSTER)" $(WORKER_NUM)
# ------------------------------------------------------------------------------
# deploy dependencies
# ------------------------------------------------------------------------------
CP_DEP_APPS ?= kong,postgres
WP_DEP_APPS ?= kong
.PHONY: helm-apply-cp-deps
helm-apply-cp-deps:
$(MAKE) helm-apply-deps DEP_APPS=$(CP_DEP_APPS) KUBE_CTX=kind-$(CP_CLUSTER) HELM_ENV=control
.PHONY: helm-apply-wp-deps
helm-apply-wp-deps:
kind get clusters|grep $(WP_CLUSTER)|xargs -n1 -I{} $(MAKE) helm-apply-deps DEP_APPS=$(WP_DEP_APPS) KUBE_CTX=kind-{} HELM_ENV=worker
.PHONY: helm-apply-deps
helm-apply-deps:
hack/helm-apply-deps.sh $(CLONE_PATH) $(DEP_APPS) $(KUBE_CTX) $(HELM_ENV)
# ------------------------------------------------------------------------------
# deploy llmariner
# ------------------------------------------------------------------------------
EXTRA_CP_VALS ?= values-cp.yaml
EXTRA_WP_VALS ?= values-wp.yaml
.PHONY: helm-apply-cp-llma
helm-apply-cp-llma:
$(MAKE) helm-apply-llma EXTRA_VALS=$(EXTRA_CP_VALS) KUBE_CTX=kind-$(CP_CLUSTER) HELM_ENV=control
.PHONY: helm-apply-wp-llma
helm-apply-wp-llma:
for cluster in $(shell kind get clusters | grep $(WP_CLUSTER)); do \
export REGISTRATION_KEY=$$(cat $(CLONE_PATH)/.regkey-kind-$$cluster||curl --request POST http://localhost:8080/v1/clusters -d "{\"name\":\"$$cluster\"}"|jq -r .registration_key); \
echo "$$REGISTRATION_KEY" > $(CLONE_PATH)/.regkey-kind-$$cluster; \
$(MAKE) helm-apply-llma EXTRA_VALS=$(EXTRA_WP_VALS) KUBE_CTX=kind-$$cluster HELM_ENV=worker; \
done
.PHONY: helm-apply-llma
helm-apply-llma:
hack/helm-apply-llma.sh $(CLONE_PATH) $(EXTRA_VALS) $(KUBE_CTX) $(HELM_ENV)
# ------------------------------------------------------------------------------
# load images
# ------------------------------------------------------------------------------
.PHONY: load-server-image
load-server-image: build-docker-server
@kind load docker-image $(SERVER_IMAGE):$(TAG) --name $(CP_CLUSTER)
.PHONY: load-dispatcher-image
load-dispatcher-image: build-docker-dispatcher
@kind get clusters|grep $(WP_CLUSTER)|xargs -n1 kind load docker-image $(DISPATCHER_IMAGE):$(TAG) --name
# ------------------------------------------------------------------------------
# rollout pods
# ------------------------------------------------------------------------------
.PHONY: rollout-job-server
rollout-job-server:
@kubectl --context kind-$(CP_CLUSTER) rollout restart deployment -n llmariner job-manager-server
.PHONY: rollout-job-dispatcher
rollout-job-dispatcher:
@kind get clusters|grep $(WP_CLUSTER)|xargs -n1 -I{} kubectl --context kind-{} rollout restart deployment -n llmariner job-manager-dispatcher