-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathTaskfile.helper.yml
463 lines (422 loc) · 15.9 KB
/
Taskfile.helper.yml
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
version: 3
output: prefixed
silent: false
vars:
nodes:
ref: until (env "SOLO_NETWORK_SIZE" | default .SOLO_NETWORK_SIZE | int)
# node name should be node1, node2, node3, etc.
node_list_internal: "{{range $idx, $n := .nodes }}node{{add $n 1}},{{end}}"
node_identifiers: "{{ .node_list_internal | trimSuffix \",\" }}"
solo_user_dir: "{{ .solo_home_override_dir | default (printf \"%s/.solo\" (env \"HOME\")) }}"
solo_cache_dir: "{{ .solo_user_dir }}/cache"
solo_logs_dir: "{{ .solo_user_dir }}/logs"
solo_keys_dir: "{{ .solo_cache_dir }}/keys"
solo_bin_dir: "{{ .solo_user_dir }}/bin"
temp_prefix:
sh: (echo "/tmp/solo-${USER}-$(date +%Y%m%d%H%M%S)")
run_build_file:
sh: (echo "/tmp/solo-${USER}-run-build-$(date +%Y%m%d%H%M%S)")
var_check_file:
sh: (echo "/tmp/solo-${USER}-var-check-$(date +%Y%m%d%H%M%S)")
minio_flag_file:
sh: (echo "/tmp/solo-${USER}-minio-flag-$(date +%Y%m%d%H%M%S)")
solo_install_file:
sh: (echo "/tmp/solo-${USER}-solo-install-$(date +%Y%m%d%H%M%S)")
env:
SOLO_CLUSTER_SETUP_NAMESPACE: solo-setup
SOLO_CLUSTER_RELEASE_NAME: solo-cluster-setup
SOLO_CLUSTER_NAME: solo-cluster
MIRROR_RELEASE_NAME: mirror
tasks:
init:
cmds:
- task: "install:solo"
- task: "var:check"
- task: "run:build"
var:check:
silent: true
status:
- test -f {{ .var_check_file }}
requires:
vars:
- solo_user_dir
- solo_cache_dir
- solo_logs_dir
- solo_keys_dir
- solo_bin_dir
- nodes
- node_list_internal
- node_identifiers
- run_build_file
- SOLO_NAMESPACE
- SOLO_CLUSTER_SETUP_NAMESPACE
- SOLO_CLUSTER_RELEASE_NAME
- SOLO_NETWORK_SIZE
- SOLO_CLUSTER_NAME
- MIRROR_RELEASE_NAME
cmds:
- echo "Checking variables..."
- echo "solo_user_dir={{ .solo_user_dir }}"
- echo "SOLO_HOME=${SOLO_HOME}"
- echo "SOLO_NETWORK_SIZE=${SOLO_NETWORK_SIZE}"
- echo "SOLO_CHART_VERSION=${SOLO_CHART_VERSION}"
- echo "CONSENSUS_NODE_VERSION=${CONSENSUS_NODE_VERSION}"
- echo "SOLO_NAMESPACE=${SOLO_NAMESPACE}"
- echo "SOLO_CLUSTER_RELEASE_NAME=${SOLO_CLUSTER_RELEASE_NAME}"
- echo "nodes={{ .nodes }}"
- echo "node_identifiers={{ .node_identifiers }}"
- echo "use_port_forwards={{ .use_port_forwards }}"
- echo "VALUES_FLAG=${VALUES_FLAG}"
- echo "SETTINGS_FLAG=${SETTINGS_FLAG}"
- echo "LOG4J2_FLAG=${LOG4J2_FLAG}"
- echo "APPLICATION_PROPERTIES_FLAG=${APPLICATION_PROPERTIES_FLAG}"
- echo "LOCAL_BUILD_FLAG=${LOCAL_BUILD_FLAG}"
- echo "DEBUG_NODE_ALIAS=${DEBUG_NODE_ALIAS}"
- echo "SOLO_CHARTS_DIR_FLAG=${SOLO_CHARTS_DIR_FLAG}"
- echo "LOAD_BALANCER_FLAG=${LOAD_BALANCER_FLAG}"
- echo "ENABLE_EXPLORER_TLS_FLAG=${ENABLE_EXPLORER_TLS_FLAG}"
- echo "CLUSTER_TLS_FLAGS=${CLUSTER_TLS_FLAGS}"
- echo "NETWORK_DEPLOY_EXTRA_FLAGS=${NETWORK_DEPLOY_EXTRA_FLAGS}"
- echo "MIRROR_NODE_DEPLOY_EXTRA_FLAGS=${MIRROR_NODE_DEPLOY_EXTRA_FLAGS}"
- touch {{ .var_check_file }}
readme:
silent: true
cmds:
- echo "This is a custom network configuration for the Hedera Hashgraph Solo network."
- echo "The network is configured to have {{ .SOLO_NETWORK_SIZE }} nodes."
- echo "The network is deployed in the namespace {{ .SOLO_NAMESPACE }}."
- echo "The cluster is deployed in the namespace {{ .SOLO_CLUSTER_SETUP_NAMESPACE }}."
- echo "Use command 'task default' to deploy the network."
- echo "Use command 'task destroy' to destroy the network."
- echo "Use command 'task clean' to destroy and clean up the network."
- echo "Use command 'task show:ips' to show the external IPs of the nodes."
- echo "Use command 'task default-with-mirror' to deploy the network with a mirror node."
- echo "Use command 'task default-with-relay' to deploy the network with a relay node."
install:solo:
silent: true
internal: true
status:
- test -f {{ .solo_install_file }}
cmds:
- |
if [[ "$(ls -1 package.json > /dev/null 2>&1)" == "" ]]; then
cd ..
fi
pwd
- npm install
- touch {{ .solo_install_file }}
install:kubectl:darwin:
silent: true
internal: true
platforms:
- darwin
status:
- command -v kubectl
cmds:
- brew update
- brew install kubernetes-cli
install:kubectl:linux:
silent: true
internal: true
platforms:
- linux
status:
- command -v kubectl
cmds:
- curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/{{ ARCH }}/kubectl"
- sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
- rm -rf kubectl
solo:init:
internal: true
silent: true
deps:
- task: "init"
status:
- test -f {{ .solo_bin_dir }}/helm
- test -f {{ .solo_cache_dir }}/profiles/custom-spec.yaml
- test -f {{ .solo_cache_dir }}/templates/api-permission.properties
- test -f {{ .solo_cache_dir }}/templates/application.properties
- test -f {{ .solo_cache_dir }}/templates/bootstrap.properties
- test -f {{ .solo_cache_dir }}/templates/settings.txt
- test -f {{ .solo_cache_dir }}/templates/log4j2.xml
#- test "$(yq -r '.flags."node-ids"' < {{ .solo_user_dir }}/solo.yaml)" == "{{ .node_identifiers }}"
- test "$(jq -r '.flags."node-ids"' < {{ .solo_user_dir }}/solo.config)" == "{{ .node_identifiers }}"
cmds:
- SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- init --dev
solo:keys:
silent: true
internal: true
status:
- |
for n in $(seq 0 {{ sub (env "SOLO_NETWORK_SIZE" | default .SOLO_NETWORK_SIZE | int) 1 }}); do
test -f {{ .solo_keys_dir }}/hedera-node${n}.crt
test -f {{ .solo_keys_dir }}/hedera-node${n}.key
test -f {{ .solo_keys_dir }}/s-public-node${n}.pem
test -f {{ .solo_keys_dir }}/s-private-node${n}.pem
done
deps:
- task: "init"
cmds:
- SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- node keys --gossip-keys --tls-keys --node-aliases-unparsed {{.node_identifiers}} -q --dev
solo:network:deploy:
silent: true
internal: true
deps:
- task: "init"
cmds:
- |
if [[ "${DEBUG_NODE_ALIAS}" != "" ]]; then
export DEBUG_NODE_FLAG="--debug-node-alias {{ .DEBUG_NODE_ALIAS }}"
fi
if [[ "${CONSENSUS_NODE_VERSION}" != "" ]]; then
export CONSENSUS_NODE_FLAG='--release-tag {{.CONSENSUS_NODE_VERSION}}'
fi
if [[ "${SOLO_CHART_VERSION}" != "" ]]; then
export SOLO_CHART_FLAG='--solo-chart-version ${SOLO_CHART_VERSION}'
fi
SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- network deploy --namespace "${SOLO_NAMESPACE}" --node-aliases-unparsed {{.node_identifiers}} ${CONSENSUS_NODE_FLAG} ${SOLO_CHART_FLAG} ${VALUES_FLAG} ${SETTINGS_FLAG} ${LOG4J2_FLAG} ${APPLICATION_PROPERTIES_FLAG} ${GENESIS_THROTTLES_FLAG} ${DEBUG_NODE_FLAG} ${SOLO_CHARTS_DIR_FLAG} ${LOAD_BALANCER_FLAG} ${NETWORK_DEPLOY_EXTRA_FLAGS} -q --dev
- task: "solo:node:setup"
solo:node:setup:
silent: true
internal: true
deps:
- task: "init"
cmds:
- |
if [[ "${CONSENSUS_NODE_VERSION}" != "" ]]; then
export CONSENSUS_NODE_FLAG='--release-tag ${CONSENSUS_NODE_VERSION}'
fi
SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- node setup --namespace "${SOLO_NAMESPACE}" --node-aliases-unparsed {{.node_identifiers}} ${CONSENSUS_NODE_FLAG} ${LOCAL_BUILD_FLAG} -q --dev
solo:network:destroy:
silent: true
internal: true
deps:
- task: "init"
cmds:
- SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- network destroy --namespace "${SOLO_NAMESPACE}" --delete-pvcs --delete-secrets --force -q --dev
solo:node:start:
silent: true
internal: true
deps:
- task: "init"
cmds:
- |
if [[ "${DEBUG_NODE_ALIAS}" != "" ]]; then
export DEBUG_NODE_FLAG="--debug-node-alias {{ .DEBUG_NODE_ALIAS }}"
fi
SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- node start --namespace "${SOLO_NAMESPACE}" --node-aliases-unparsed {{.node_identifiers}} ${DEBUG_NODE_FLAG} -q {{ .CLI_ARGS }} --dev
- |
if [[ "{{ .use_port_forwards }}" == "true" ]];then
echo "Port forwarding for Hedera Network Node: grpc:50211"
/bin/bash -c "nohup kubectl port-forward -n \"${SOLO_NAMESPACE}\" svc/haproxy-node1-svc 50211:50211 > /dev/null 2>&1 &"
sleep 4
fi
solo:node:stop:
silent: true
internal: true
ignore_error: true
deps:
- task: "init"
cmds:
- SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- node stop --namespace "${SOLO_NAMESPACE}" --node-aliases-unparsed {{.node_identifiers}} -q {{ .CLI_ARGS }} --dev
solo:relay:
silent: true
deps:
- task: "init"
cmds:
- SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- relay deploy -n "${SOLO_NAMESPACE}" -i node1 ${RELAY_NODE_DEPLOY_EXTRA_FLAGS} -q --dev
- |
if [[ "{{ .use_port_forwards }}" == "true" ]];then
echo "Enable port forwarding for Hedera JSON RPC Relay"
/bin/bash -c "nohup kubectl port-forward -n \"${SOLO_NAMESPACE}\" svc/relay-node1-hedera-json-rpc-relay 7546:7546 > /dev/null 2>&1 &"
sleep 4
fi
solo:destroy-relay:
silent: true
status:
- |
{{.solo_bin_dir}}/helm list -n "${SOLO_NAMESPACE}" | grep -vqz relay-node1
deps:
- task: "init"
cmds:
- SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- relay destroy -n "${SOLO_NAMESPACE}" -i node1 -q --dev
solo:cache:remove:
silent: true
internal: true
status:
- test [[ ! -d {{ .solo_cache_dir }} ]]
cmds:
- echo "Removing solo cache directory..."
- rm -rf {{ .solo_cache_dir }}
solo:logs:remove:
silent: true
internal: true
status:
- test [[ ! -d {{ .solo_logs_dir }} ]]
cmds:
- echo "Removing solo logs directory..."
- rm -rf {{ .solo_logs_dir }}
solo:config:remove:
silent: true
internal: true
status:
- test [[ ! -f {{ .solo_user_dir }}/solo.yaml ]]
cmds:
- echo "Removing solo config..."
- rm -rf {{ .solo_user_dir }}/solo.yaml
solo:freeze:restart:
cmds:
- SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- node prepare-upgrade --namespace "${SOLO_NAMESPACE}" -q --dev
- SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- node freeze-upgrade --namespace "${SOLO_NAMESPACE}" -q --dev
- SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- node stop --namespace "${SOLO_NAMESPACE}" --node-aliases-unparsed {{.node_identifiers}} -q --dev
- SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- node start --namespace "${SOLO_NAMESPACE}" --node-aliases-unparsed {{.node_identifiers}} -q --dev
cluster:create:
silent: true
status:
- kind get clusters | grep -q "${SOLO_CLUSTER_NAME}"
cmds:
- kind create cluster -n "${SOLO_CLUSTER_NAME}" --image "${KIND_IMAGE}"
- sleep 10 # wait for control plane to come up
- kubectl config set-context kind-${SOLO_CLUSTER_NAME}
cluster:destroy:
silent: true
cmds:
- kind delete cluster --name "${SOLO_CLUSTER_NAME}"
clean:port-forward:
silent: true
cmds:
- echo "Cleaning up port forwards..."
- |
if [[ "{{ .use_port_forwards }}" == "true" ]];then
pkill -f "kubectl port-forward -n {{ .SOLO_NAMESPACE }}" | grep -w ${UID} || true
fi
run:build:
silent: true
status:
- test -f {{ .run_build_file }}
cmds:
- npm run build
- touch {{ .run_build_file }}
solo:cluster:minio:
internal: true
silent: true
cmds:
- |
if ! kubectl get svc -l app.kubernetes.io/instance=minio-operator --all-namespaces --no-headers | grep -q . ; then
echo "No services found with label app.kubernetes.io/name=operator app.kubernetes.io/instance=minio-operator"
echo "--minio" > {{ .minio_flag_file }}
else
echo "--no-minio" > {{ .minio_flag_file }}
fi
solo:cluster:setup:
silent: true
deps:
- task: "init"
- task: "solo:cluster:minio"
status:
- |
{{.solo_bin_dir}}/helm list --all-namespaces | grep -qz "${SOLO_CLUSTER_RELEASE_NAME}"
cmds:
- |
export MINIO_FLAG=$(cat {{ .minio_flag_file }})
SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- cluster setup --cluster-setup-namespace "${SOLO_CLUSTER_SETUP_NAMESPACE}" ${MINIO_FLAG} ${SOLO_CHARTS_DIR_FLAG} ${CLUSTER_TLS_FLAGS} -q --dev
solo:node:addresses:
internal: true
silent: true
cmds:
- |
echo "External IPs of the network nodes:"
export IP_LIST_TEMPLATE_FILE={{ .TASKFILE_DIR }}/list-external-ips.gotemplate
kubectl get svc -n "${SOLO_NAMESPACE}" -l "solo.hedera.com/type=network-node-svc" --output=go-template-file=${IP_LIST_TEMPLATE_FILE}
solo:node:logs:
silent: true
cmds:
- SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- node logs --namespace "${SOLO_NAMESPACE}" --node-aliases-unparsed {{.node_identifiers}} -q --dev
start:
desc: solo node start
deps:
- task: "init"
cmds:
- task: "solo:node:start"
stop:
desc: solo node stop
deps:
- task: "init"
cmds:
- task: "solo:node:stop"
show:ips:
deps:
- task: "init"
cmds:
- task: "solo:node:addresses"
clean:cache:
desc: remove solo cache directory
deps:
- task: "init"
cmds:
- task: "solo:cache:remove"
clean:logs:
desc: remove solo logs director
deps:
- task: "init"
cmds:
- task: "solo:logs:remove"
default-with-mirror:
desc: in addition to the defaults, also deploy the mirror node
deps:
- task: "init"
cmds:
- task: "default"
- task: "solo:mirror-node"
default-with-relay:
desc: in addition to default-with-mirror, deploy the JSON RPC relay
deps:
- task: "init"
cmds:
- task: "default"
- task: "solo:mirror-node"
- task: "solo:relay"
solo:mirror-node:
silent: true
desc: solo mirror-node deploy with port forward on explorer
deps:
- task: "init"
cmds:
- SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- mirror-node deploy --namespace "${SOLO_NAMESPACE}" -s ${SOLO_CLUSTER_SETUP_NAMESPACE} ${SOLO_CHARTS_DIR_FLAG} ${ENABLE_EXPLORER_TLS_FLAG} ${TLS_CLUSTER_ISSUER_TYPE_FLAG} ${MIRROR_NODE_DEPLOY_EXTRA_FLAGS} --pinger -q --dev
- |
if [[ "{{ .use_port_forwards }}" == "true" ]];then
echo "Enable port forwarding for Hedera Explorer & Mirror Node Network"
echo "Port forwarding for Hedera Explorer: http://localhost:6789"
/bin/bash -c "nohup kubectl port-forward -n \"${SOLO_NAMESPACE}\" svc/hedera-explorer 8080:80 > /dev/null 2>&1 &"
echo "Port forwarding for Mirror Node Network: grpc:5600, rest:5551"
/bin/bash -c "nohup kubectl port-forward -n \"${SOLO_NAMESPACE}\" svc/mirror-grpc 5600:5600 > /dev/null 2>&1 &"
/bin/bash -c "nohup kubectl port-forward -n \"${SOLO_NAMESPACE}\" svc/mirror-rest 5551:80 > /dev/null 2>&1 &"
sleep 4
fi
solo:destroy-mirror-node:
silent: true
desc: solo mirror-node destroy
status:
- |
{{.solo_bin_dir}}/helm list -n "${SOLO_NAMESPACE}" | grep -vqz "${MIRROR_RELEASE_NAME}"
deps:
- task: "init"
cmds:
- SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- mirror-node destroy --namespace "${SOLO_NAMESPACE}" --force -q --dev || true
clean:
desc: destroy, then remove cache directory, logs directory, config, and port forwards
deps:
- task: "init"
cmds:
- task: "destroy"
- task: "clean:cache"
- task: "clean:logs"
- task: "solo:config:remove"
- task: "clean:port-forward"
- task: "clean:tmp"
clean:tmp:
desc: remove temporary files
silent: true
cmds:
- echo "Cleaning up temporary files..."
- rm -f /tmp/solo-${USER}-* || true