|
| 1 | +version: 3 |
| 2 | +output: prefixed |
| 3 | +silent: false |
| 4 | +vars: |
| 5 | + nodes: |
| 6 | + ref: until (env "SOLO_NETWORK_SIZE" | default .SOLO_NETWORK_SIZE | int) |
| 7 | + # node name should be node1, node2, node3, etc. |
| 8 | + node_list_internal: "{{range $idx, $n := .nodes }}node{{add $n 1}},{{end}}" |
| 9 | + node_identifiers: "{{ .node_list_internal | trimSuffix \",\" }}" |
| 10 | + |
| 11 | + solo_user_dir: "{{ env \"HOME\" }}/.solo" |
| 12 | + solo_cache_dir: "{{ .solo_user_dir }}/cache" |
| 13 | + solo_logs_dir: "{{ .solo_user_dir }}/logs" |
| 14 | + solo_keys_dir: "{{ .solo_cache_dir }}/keys" |
| 15 | + solo_bin_dir: "{{ .solo_user_dir }}/bin" |
| 16 | + |
| 17 | +tasks: |
| 18 | + readme: |
| 19 | + silent: true |
| 20 | + cmds: |
| 21 | + - echo "This is a custom network configuration for the Hedera Hashgraph Solo network." |
| 22 | + - echo "The network is configured to have {{ .SOLO_NETWORK_SIZE }} nodes." |
| 23 | + - echo "The network is deployed in the namespace {{ .SOLO_NAMESPACE }}." |
| 24 | + - echo "The cluster is deployed in the namespace {{ .SOLO_CLUSTER_SETUP_NAMESPACE }}." |
| 25 | + - echo "Use command 'task default' to deploy the network." |
| 26 | + - echo "Use command 'task destroy' to destroy the network." |
| 27 | + - echo "Use command 'task clean' to destroy and clean up the network." |
| 28 | + - echo "Use command 'task show:ips' to show the external IPs of the nodes." |
| 29 | + - echo "Use command 'task default-with-mirror' to deploy the network with a mirror node." |
| 30 | + - echo "Use command 'task default-with-relay' to deploy the network with a relay node." |
| 31 | + |
| 32 | + install:solo: |
| 33 | + internal: true |
| 34 | + status: |
| 35 | + - command -v solo |
| 36 | + cmds: |
| 37 | + - npm install -g @hashgraph/solo |
| 38 | + - cd ../.. |
| 39 | + - npm link |
| 40 | + |
| 41 | + install:kubectl:darwin: |
| 42 | + internal: true |
| 43 | + platforms: |
| 44 | + - darwin |
| 45 | + status: |
| 46 | + - command -v kubectl |
| 47 | + cmds: |
| 48 | + - brew update |
| 49 | + - brew install kubernetes-cli |
| 50 | + |
| 51 | + install:kubectl:linux: |
| 52 | + internal: true |
| 53 | + platforms: |
| 54 | + - linux |
| 55 | + status: |
| 56 | + - command -v kubectl |
| 57 | + cmds: |
| 58 | + - curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/{{ ARCH }}/kubectl" |
| 59 | + - sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl |
| 60 | + - rm -rf kubectl |
| 61 | + |
| 62 | + solo:init: |
| 63 | + internal: true |
| 64 | + status: |
| 65 | + - test -f {{ .solo_bin_dir }}/helm |
| 66 | + - test -f {{ .solo_cache_dir }}/profiles/custom-spec.yaml |
| 67 | + - test -f {{ .solo_cache_dir }}/templates/api-permission.properties |
| 68 | + - test -f {{ .solo_cache_dir }}/templates/application.properties |
| 69 | + - test -f {{ .solo_cache_dir }}/templates/bootstrap.properties |
| 70 | + - test -f {{ .solo_cache_dir }}/templates/settings.txt |
| 71 | + - test -f {{ .solo_cache_dir }}/templates/log4j2.xml |
| 72 | + #- test "$(yq -r '.flags."node-ids"' < {{ .solo_user_dir }}/solo.yaml)" == "{{ .node_identifiers }}" |
| 73 | + - test "$(jq -r '.flags."node-ids"' < {{ .solo_user_dir }}/solo.config)" == "{{ .node_identifiers }}" |
| 74 | + cmds: |
| 75 | + - npm run build |
| 76 | + - solo init |
| 77 | + |
| 78 | + solo:keys: |
| 79 | + internal: true |
| 80 | + status: |
| 81 | + - | |
| 82 | + for n in $(seq 0 {{ sub (env "SOLO_NETWORK_SIZE" | default .SOLO_NETWORK_SIZE | int) 1 }}); do |
| 83 | + test -f {{ .solo_keys_dir }}/hedera-node${n}.crt |
| 84 | + test -f {{ .solo_keys_dir }}/hedera-node${n}.key |
| 85 | + test -f {{ .solo_keys_dir }}/s-public-node${n}.pem |
| 86 | + test -f {{ .solo_keys_dir }}/s-private-node${n}.pem |
| 87 | + done |
| 88 | + cmds: |
| 89 | + - npm run build |
| 90 | + - solo node keys --gossip-keys --tls-keys --node-aliases-unparsed {{.node_identifiers}} |
| 91 | + |
| 92 | + solo:network:deploy: |
| 93 | + internal: true |
| 94 | + cmds: |
| 95 | + - npm run build |
| 96 | + - solo network deploy --namespace "${SOLO_NAMESPACE}" --node-aliases-unparsed {{.node_identifiers}} --release-tag "${CONSENSUS_NODE_VERSION}" --solo-chart-version "${SOLO_CHART_VERSION}" |
| 97 | + - solo node setup --namespace "${SOLO_NAMESPACE}" --node-aliases-unparsed {{.node_identifiers}} --release-tag "${CONSENSUS_NODE_VERSION}" |
| 98 | + |
| 99 | + solo:network:destroy: |
| 100 | + internal: true |
| 101 | + cmds: |
| 102 | + - npm run build |
| 103 | + - solo network destroy --namespace "${SOLO_NAMESPACE}" --delete-pvcs --delete-secrets --force |
| 104 | + |
| 105 | + solo:node:start: |
| 106 | + internal: true |
| 107 | + cmds: |
| 108 | + - npm run build |
| 109 | + - solo node start --namespace "${SOLO_NAMESPACE}" --node-aliases-unparsed {{.node_identifiers}} {{ .CLI_ARGS }} |
| 110 | + - kubectl port-forward -n "${SOLO_NAMESPACE}" svc/haproxy-node1-svc 50211:50211 & |
| 111 | + - task: "sleep_after_port_forward" |
| 112 | + |
| 113 | + solo:node:stop: |
| 114 | + internal: true |
| 115 | + ignore_error: true |
| 116 | + cmds: |
| 117 | + - npm run build |
| 118 | + - solo node stop --namespace "${SOLO_NAMESPACE}" --node-aliases-unparsed {{.node_identifiers}} {{ .CLI_ARGS }} |
| 119 | + |
| 120 | + solo:node:addresses: |
| 121 | + internal: true |
| 122 | + cmds: |
| 123 | + - kubectl get svc -n "${SOLO_NAMESPACE}" -l "solo.hedera.com/type=network-node-svc" |
| 124 | + |
| 125 | + solo:relay: |
| 126 | + cmds: |
| 127 | + - npm run build |
| 128 | + - solo relay deploy -n "${SOLO_NAMESPACE}" -i node1 |
| 129 | + - echo "Enable port forwarding for Hedera JSON RPC Relay" |
| 130 | + - kubectl port-forward -n "${SOLO_NAMESPACE}" svc/relay-node1-hedera-json-rpc-relay 7546:7546 & |
| 131 | + - task: "sleep_after_port_forward" |
| 132 | + |
| 133 | + solo:destroy-relay: |
| 134 | + status: |
| 135 | + - helm list -n "${SOLO_NAMESPACE}" | grep -vqz relay-node1 |
| 136 | + cmds: |
| 137 | + - npm run build |
| 138 | + - solo relay destroy -n "${SOLO_NAMESPACE}" -i node1 |
| 139 | + |
| 140 | + solo:cache:remove: |
| 141 | + internal: true |
| 142 | + status: |
| 143 | + - test [[ ! -d {{ .solo_cache_dir }} ]] |
| 144 | + cmds: |
| 145 | + - rm -rf {{ .solo_cache_dir }} |
| 146 | + |
| 147 | + solo:logs:remove: |
| 148 | + internal: true |
| 149 | + status: |
| 150 | + - test [[ ! -d {{ .solo_logs_dir }} ]] |
| 151 | + cmds: |
| 152 | + - rm -rf {{ .solo_logs_dir }} |
| 153 | + |
| 154 | + solo:config:remove: |
| 155 | + internal: true |
| 156 | + status: |
| 157 | + - test [[ ! -f {{ .solo_user_dir }}/solo.yaml ]] |
| 158 | + cmds: |
| 159 | + - rm -rf {{ .solo_user_dir }}/solo.yaml |
| 160 | + |
| 161 | + cluster:create: |
| 162 | + status: |
| 163 | + - kind get clusters | grep -q "${SOLO_CLUSTER_NAME}" |
| 164 | + cmds: |
| 165 | + - kind create cluster -n "${SOLO_CLUSTER_NAME}" --image "${KIND_IMAGE}" |
| 166 | + |
| 167 | + cluster:setup: |
| 168 | + cmds: |
| 169 | + - npm run build |
| 170 | + - solo cluster setup --cluster-setup-namespace "${SOLO_CLUSTER_SETUP_NAMESPACE}" |
| 171 | + |
| 172 | + cluster:destroy: |
| 173 | + cmds: |
| 174 | + - kind delete cluster --name "${SOLO_CLUSTER_NAME}" |
| 175 | + |
| 176 | + clean:port-forward: |
| 177 | + cmds: |
| 178 | + - pkill -f "kubectl port-forward -n {{ .SOLO_NAMESPACE }}" || true |
| 179 | + |
| 180 | + sleep_after_port_forward: |
| 181 | + cmds: |
| 182 | + # somehow without the sleep, when port-forward is the last command of a series of tasks, port-forward |
| 183 | + # prematurely killed when task is exiting |
| 184 | + - sleep 4 |
0 commit comments