forked from ovrclk/disco
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.mk
146 lines (107 loc) · 5.57 KB
/
make.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
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
NODE ?= node1
L3_DOMAIN = akashtest.net
CONFIG_DIR ?= $(L3DIR)/.data
PROVIDER ?= alice
REGION ?= sjc
IMAGE_TAG ?= 0.5.4-rc3
AKASH_NS ?= akash-sys
HELM_REPO = helm.akash.network
HELM_FLAGS = --repo $(HELM_REPO) --dry-run --debug
akashd-init:
mkdir -p $(DBCFG)/nodes
akashd init -t helm -o $(DBCFG)/nodes -n $(call join-with,$(comma),$(DB_NODES)) $(shell akash key show master --public)
akash-remove: delmanifests
$(KC) helm list | grep akash-sys | awk '{print $$1}' | xargs helm del --purge $(HELM_FLAGS)
$(KC) kubectl delete namespace $(AKASH_NS)
akash-node-install:
$(KC) kubectl create namespace $(AKASH_NS) || true
$(KC) helm install $(HELM_FLAGS) akash-node --namespace=$(AKASH_NS) \
--name $(NODE) \
--set "image.tag=$(IMAGE_TAG)" \
--set "ingress.domain=$(NODE).$(L3_DOMAIN)" -f $(DBCFG)/nodes/$(NODE).yaml
akash-node-install-all:
$(foreach node, $(NODES), $(MAKE) akash-node-install.$(node))
akash-node-install.%:
$(eval node := $(@:akash-node-install.%=%))
$(MAKE) NODE=$(node) akash-node-install || true
.PHONY: .PHONY akash-node-install akash-node-install.% akash-node-install-all
akash-node-remove:
$(KC) helm del --purge $(NODE)
akash-node-remove-all:
$(foreach node, $(NODES), $(MAKE) akash-node-remove.$(node))
akash-node-remove.%:
$(eval node := $(@:akash-node-remove.%=%))
$(MAKE) NODE=$(node) akash-node-remove || true
.PHONY: .PHONY akash-node-remove akash-node-remove.% akash-node-remove-all
akash-provider-gen:
[[ -f "$(DBCFG)/providers/$(PROVIDER).yml" ]] \
|| sed 's/%%HOST_URI%%/http:\/\/$(PROVIDER).$(L3_DOMAIN)/g; s/%%REGION%%/$(REGION)/g' $(L3DIR)/provider.template.yaml > $(DBCFG)/providers/$(PROVIDER).yml
akash-provider-register: akash-provider-gen
[[ -f "$(DB)/keys/$(PROVIDER).address" ]] || akash provider add $(DBCFG)/providers/$(PROVIDER).yml -k $(PROVIDER) \
| grep Key: \
| awk '{print $$2}' > $(DB)/keys/$(PROVIDER).address
.PHONY: .PHONY akash-provider-register
akash-provider-install: akash-provider-key-install akash-provider-register
$(KC) kubectl create namespace $(AKASH_NS) || true
$(KC) helm install $(HELM_FLAGS) akash-provider --namespace=$(AKASH_NS) \
--name "$(PROVIDER)" \
--set "image.tag=$(IMAGE_TAG)" \
--set "ingress.domain=$(PROVIDER).$(L3_DOMAIN)" \
--set "provider.address=$(shell cat $(DBKEY)/$(PROVIDER).address)"
akash-provider-remove: akash-provider-key-remove
$(KC) helm del --purge $(PROVIDER)
.PHONY: .PHONY akash-provider-install akash-provider-remove
akash-provider-install-all:
$(foreach provider, $(DB_PROVIDERS), $(MAKE) akash-provider-install.$(provider))
akash-provider-install.%:
$(eval provider := $(@:akash-provider-install.%=%))
$(eval host := $(shell cat $(DBKEY)/$(provider).host) )
$(MAKE) HOST=$(host) PROVIDER=$(provider) akash-provider-install || true
.PHONY: .PHONY akash-provider-install akash-provider-install.% akash-provider-install-all
akash-provider-remove-all:
$(foreach provider, $(DB_PROVIDERS), $(MAKE) akash-provider-remove.$(provider))
akash-provider-remove.%:
$(eval provider := $(@:akash-provider-remove.%=%))
$(eval host := $(shell cat $(DBKEY)/$(provider).host) )
$(MAKE) HOST=$(host) PROVIDER=$(provider) akash-provider-remove || true
.PHONY: .PHONY akash-provider-remove akash-provider-remove.% akash-provider-remove-all
akash-provider-key-install:
$(KCTL) create namespace $(AKASH_NS) || true
akash key show $(PROVIDER) --private > $(DB)/keys/$(PROVIDER).private
$(KCTL) create --namespace $(AKASH_NS) secret generic $(PROVIDER)-akash-provider-private-key \
--from-file=$(DB)/keys/$(PROVIDER).private
akash-provider-key-remove:
$(KC) kubectl delete secret --namespace=$(AKASH_NS) $(PROVIDER)-akash-provider-private-key
.PHONY: .PHONY akash-provider-key-install akash-provider-key-remove
akash-provider-restart-all:
$(foreach provider, $(DB_PROVIDERS), $(MAKE) akash-provider-restart.$(provider))
akash-provider-restart.%:
$(eval provider := $(@:akash-provider-restart.%=%))
$(eval host := $(shell cat $(DBKEY)/$(provider).host) )
KUBECONFIG=$(DB)/config/kube/$(host) kubectl delete pods -n $(AKASH_NS) -l release=$(provider) || true
.PHONY: .PHONY akash-provider-restart.% akash-provider-restart-all
akash-provider-reset-all:
$(foreach provider, $(DB_PROVIDERS), $(MAKE) akash-provider-reset.$(provider))
akash-provider-reset.%:
$(eval provider := $(@:akash-provider-reset.%=%))
$(eval host := $(shell cat $(DBKEY)/$(provider).host) )
$(MAKE) HOST=$(host) PROVIDER=$(provider) akash-provider-remove || true
$(MAKE) HOST=$(host) PROVIDER=$(provider) akash-provider-install || true
.PHONY: .PHONY akash-provider-reset.% akash-provider-reset-all
akash-provider-check-all:
$(foreach provider, $(DB_PROVIDERS), $(MAKE) akash-provider-check.$(provider))
akash-provider-check.%:
$(eval provider := $(@:akash-provider-check.%=%))
$(eval host := $(shell cat $(DBKEY)/$(provider).host) )
KUBECONFIG=$(DB)/config/kube/$(host) kubectl get pods -n $(AKASH_NS) -l release=$(provider) || true
.PHONY: .PHONY akash-provider-check.% akash-provider-check-all
deldeps:
for d in "$(shell akash query deployment -k master | grep ACTIVE | awk '{print $$1}')" ;do akash deployment close $$d -k master ; done
akash-provider-delmani-all:
$(foreach provider, $(DB_PROVIDERS), $(MAKE) akash-provider-delmani.$(provider))
akash-provider-delmani.%:
$(eval provider := $(@:akash-provider-delmani.%=%))
$(eval host := $(shell cat $(DBKEY)/$(provider).host) )
KUBECONFIG=$(DB)/config/kube/$(host) kubectl get manifests -n lease | awk '{print $$1}' | xargs kubectl delete manifest -n lease || true
delmanifests:
$(KC) kubectl get manifests -n lease | awk '{print $$1}' | xargs kubectl delete manifest -n lease