Browse Source

Add volumeSize input, update endpoints

Anuj Bansal 3 years ago
parent
commit
8f02bc9b4c

+ 8 - 4
.github/workflows/deploy-node-network.yml

@@ -39,6 +39,7 @@ jobs:
           echo ::set-output name=ec2AMI::$(echo $jsonInput | jq -r '.ec2AMI.value')
           echo ::set-output name=networkSuffix::$(echo $jsonInput | jq -r '.networkSuffix.value')
           echo ::set-output name=deploymentType::$(echo $jsonInput | jq -r '.deploymentType.value')
+          echo ::set-output name=volumeSize::$(echo $jsonInput | jq -r '.volumeSize.value')
           initialBalancesFile=$(echo $jsonInput | jq -r '.initialBalancesFile.value')
           initialMembersFile=$(echo $jsonInput | jq -r '.initialMembersFile.value')
           if [ -z "$initialBalancesFile" ]
@@ -89,7 +90,8 @@ jobs:
             RPCEC2InstanceType=${{ steps.myoutputs.outputs.rpcInstanceType }},
             BuildEC2InstanceType=${{ steps.myoutputs.outputs.buildInstanceType }},
             EC2AMI=${{ steps.myoutputs.outputs.ec2AMI }},
-            NumberOfValidators=${{ steps.myoutputs.outputs.numberOfValidators }}
+            NumberOfValidators=${{ steps.myoutputs.outputs.numberOfValidators }},
+            VolumeSize=${{ steps.myoutputs.outputs.volumeSize }}
 
       - name: Prepare inventory for Ansible
         run: |
@@ -162,9 +164,11 @@ jobs:
           name: data-chainspec-auth
           path: devops/aws/chain-data.7z
 
-      - name: Print output URL's
-        run: |
-          echo -e "RPC: wss://${{ steps.deploy_stack.outputs.RPCPublicIp }}.nip.io/ws-rpc"
+      - name: Save the endpoints file as an artifact
+        uses: actions/upload-artifact@v2
+        with:
+          name: endpoints
+          path: devops/aws/endpoints.json
 
       - name: Delete CloudFormation Stack if any step failed
         # Skip only if stack already existed or all steps passed succesfully

+ 4 - 0
.pipelines/deploy-node-network-inputs.json

@@ -31,6 +31,10 @@
     "description": "Pre-built AMI ID (ami-095792100b6e43a67)",
     "value": "ami-095792100b6e43a67"
   },
+  "volumeSize": {
+    "description": "Instance volume size in GB",
+    "value": "120"
+  },
   "networkSuffix": {
     "description": "Network suffix that will be added to the network name",
     "value": "8129"

+ 5 - 1
devops/aws/cloudformation/infrastructure.yml

@@ -34,6 +34,10 @@ Parameters:
     Description: Number of validator instances to launch
     Type: Number
     Default: 2
+  VolumeSize:
+    Description: Instance volume size in GB
+    Type: Number
+    Default: 120
 
 Conditions:
   HasAMIId: !Not [!Equals [!Ref EC2AMI, ""]]
@@ -111,7 +115,7 @@ Resources:
         BlockDeviceMappings:
           - DeviceName: /dev/sda1
             Ebs:
-              VolumeSize: '120'
+              VolumeSize: !Ref VolumeSize
         UserData:
           Fn::Base64: !Sub |
             #!/bin/bash -xe

+ 31 - 7
devops/aws/roles/rpc/tasks/main.yml

@@ -11,8 +11,8 @@
     src: joystream-node.service.j2
     dest: /etc/systemd/system/joystream-node.service
   vars:
-    template_remote_chain_spec_path: "{{ remote_chain_spec_path }}"
-    boot_nodes: "{{ result.result.bootNodes }}"
+    template_remote_chain_spec_path: '{{ remote_chain_spec_path }}'
+    boot_nodes: '{{ result.result.bootNodes }}'
   become: yes
 
 - name: Start service joystream-node, if not started
@@ -63,9 +63,7 @@
 
 - name: Set websocket and http endpoint variables
   set_fact:
-    ws_rpc: "{{ inventory_hostname }}.nip.io/ws-rpc"
-    http_rpc: "{{ inventory_hostname }}.nip.io/http-rpc"
-    nip_domain: "{{ inventory_hostname }}.nip.io"
+    nip_domain: '{{ inventory_hostname }}.nip.io'
   run_once: yes
 
 - name: Install and configure Caddy
@@ -78,6 +76,32 @@
     caddy_systemd_capabilities_enabled: true
     caddy_update: false
 
-- name: Print RPC node DNS
+- name: Set endpoints
+  set_fact:
+    all_services: |
+      websocket_rpc: wss://{{ nip_domain }}/ws-rpc
+      http_rpc: https://{{ nip_domain }}/http-rpc
+      colossus: https://{{ nip_domain }}/colossus-1
+      distributor: https://{{ nip_domain }}/distributor-1
+      graphql_server: https://{{ nip_domain }}/query-node/server/graphql
+      graphql_server_websocket: wss://{{ nip_domain }}/query-node/server/graphql
+      indexer: https://{{ nip_domain }}/query-node/indexer/graphql
+      member_faucet: https://{{ nip_domain }}/member-faucet/register
+      config: https://{{ nip_domain }}//network/config.json
+  run_once: yes
+
+- name: Print endpoints
   debug:
-    msg: "RPC Endpoint: wss://{{ ws_rpc }}"
+    msg: '{{ all_services | from_yaml }}'
+  run_once: yes
+
+- name: Create config.json to serve as Caddy endpoint
+  copy:
+    content: '{{ all_services | from_yaml | to_json }}'
+    dest: '/home/ubuntu/config.json'
+
+- name: Save output as file on local
+  copy:
+    content: '{{ all_services | from_yaml | to_json }}'
+    dest: 'endpoints.json'
+  delegate_to: localhost

+ 15 - 2
devops/aws/roles/rpc/templates/Caddyfile.j2

@@ -1,8 +1,10 @@
-{{ ws_rpc }} {
+{{ nip_domain }}/ws-rpc* {
+    uri strip_prefix /ws-rpc
     reverse_proxy localhost:9944
 }
 
-{{ http_rpc }} {
+{{ nip_domain }}/http-rpc* {
+    uri strip_prefix /http-rpc
     reverse_proxy localhost:9933
 }
 
@@ -19,3 +21,14 @@
     uri strip_prefix /query-node/indexer
     reverse_proxy localhost:4000
 }
+
+{{ nip_domain }}/member-faucet* {
+    uri strip_prefix /member-faucet
+    reverse_proxy localhost:3002
+}
+
+{{ nip_domain }}/network/config.json {
+    root * /home/ubuntu
+    rewrite * /config.json
+    file_server
+}