Browse Source

devops: separate ansible and aws from kubernetes deployments

Mokhtar Naamani 3 years ago
parent
commit
9fd1bade66
65 changed files with 69 additions and 10 deletions
  1. 7 5
      .github/workflows/create-ami.yml
  2. 3 3
      .github/workflows/joystream-node-docker.yml
  3. 0 0
      devops/aws/.gitignore
  4. 7 1
      devops/aws/README.md
  5. 0 0
      devops/aws/ansible.cfg
  6. 0 0
      devops/aws/build-arm64-playbook.yml
  7. 0 0
      devops/aws/build-code.yml
  8. 0 0
      devops/aws/chain-spec-pioneer.yml
  9. 9 0
      devops/aws/cloudformation/infrastructure.yml
  10. 6 0
      devops/aws/cloudformation/single-instance-docker.yml
  11. 3 0
      devops/aws/cloudformation/single-instance.yml
  12. 0 0
      devops/aws/common.sh
  13. 0 0
      devops/aws/create-joystream-node-ami-playbook.yml
  14. 0 0
      devops/aws/deploy-config.sample.cfg
  15. 0 0
      devops/aws/deploy-infra.sh
  16. 0 0
      devops/aws/deploy-single-node.sh
  17. 1 1
      devops/aws/destroy-infra.sh
  18. 0 0
      devops/aws/group_vars/all
  19. 0 0
      devops/aws/library/json_modify.py
  20. 0 0
      devops/aws/requirements.yml
  21. 0 0
      devops/aws/roles/admin/tasks/deploy-pioneer.yml
  22. 0 0
      devops/aws/roles/admin/tasks/main.yml
  23. 0 0
      devops/aws/roles/common/tasks/chain-spec-node-keys.yml
  24. 0 0
      devops/aws/roles/common/tasks/get-code-git.yml
  25. 0 0
      devops/aws/roles/common/tasks/get-code-local.yml
  26. 0 0
      devops/aws/roles/common/tasks/run-setup-build.yml
  27. 0 0
      devops/aws/roles/node/templates/joystream-node.service.j2
  28. 0 0
      devops/aws/roles/rpc/tasks/main.yml
  29. 0 0
      devops/aws/roles/rpc/templates/Caddyfile.j2
  30. 0 0
      devops/aws/roles/rpc/templates/joystream-node.service.j2
  31. 0 0
      devops/aws/roles/validators/tasks/main.yml
  32. 0 0
      devops/aws/roles/validators/templates/joystream-node.service.j2
  33. 0 0
      devops/aws/setup-admin.yml
  34. 0 0
      devops/aws/single-node-playbook.yml
  35. 0 0
      devops/kubernetes/node-network/.gitignore
  36. 0 0
      devops/kubernetes/node-network/Pulumi.yaml
  37. 0 0
      devops/kubernetes/node-network/README.md
  38. 0 0
      devops/kubernetes/node-network/configMap.ts
  39. 0 0
      devops/kubernetes/node-network/index.ts
  40. 0 0
      devops/kubernetes/node-network/json_modify.py
  41. 0 0
      devops/kubernetes/node-network/nfsVolume.ts
  42. 0 0
      devops/kubernetes/node-network/package.json
  43. 0 0
      devops/kubernetes/node-network/tsconfig.json
  44. 0 0
      devops/kubernetes/node-network/utils.ts
  45. 0 0
      devops/kubernetes/node-network/validator.ts
  46. 0 0
      devops/kubernetes/pulumi-common/caddy.ts
  47. 0 0
      devops/kubernetes/pulumi-common/index.ts
  48. 0 0
      devops/kubernetes/pulumi-common/package.json
  49. 0 0
      devops/kubernetes/pulumi-common/tsconfig.json
  50. 0 0
      devops/kubernetes/query-node/.gitignore
  51. 0 0
      devops/kubernetes/query-node/Pulumi.yaml
  52. 0 0
      devops/kubernetes/query-node/README.md
  53. 0 0
      devops/kubernetes/query-node/configMap.ts
  54. 0 0
      devops/kubernetes/query-node/index.ts
  55. 31 0
      devops/kubernetes/query-node/kubeconfig
  56. 0 0
      devops/kubernetes/query-node/package.json
  57. 0 0
      devops/kubernetes/query-node/s3Helpers.ts
  58. 0 0
      devops/kubernetes/query-node/tsconfig.json
  59. 0 0
      devops/kubernetes/storage-node/.gitignore
  60. 0 0
      devops/kubernetes/storage-node/Pulumi.yaml
  61. 0 0
      devops/kubernetes/storage-node/README.md
  62. 0 0
      devops/kubernetes/storage-node/index.ts
  63. 0 0
      devops/kubernetes/storage-node/package.json
  64. 0 0
      devops/kubernetes/storage-node/tsconfig.json
  65. 2 0
      setup.sh

+ 7 - 5
.github/workflows/create-ami.yml

@@ -1,3 +1,5 @@
+# Creates an AWS AMI (system image) with compiled joystream-node and subkey
+# 
 name: Create AWS AMI
 
 on:
@@ -8,7 +10,7 @@ jobs:
     name: Build the code and run setup
     runs-on: ubuntu-latest
     env:
-      STACK_NAME: joystream-github-action-${{ github.run_number }}
+      STACK_NAME: create-joystream-node-ami-ga-${{ github.run_number }}
       KEY_NAME: joystream-github-action-key
     steps:
       - name: Extract branch name
@@ -18,7 +20,7 @@ jobs:
 
       - name: Set AMI Name environment variable
         shell: bash
-        run: echo "ami_name=joystream-${{ steps.extract_branch.outputs.branch }}-${{ github.run_number }}" >> $GITHUB_ENV
+        run: echo "ami_name=joystream-node-${{ steps.extract_branch.outputs.branch }}-${{ github.run_number }}" >> $GITHUB_ENV
         id: ami_name
 
       - name: Checkout
@@ -36,7 +38,7 @@ jobs:
         id: deploy_stack
         with:
           name: ${{ env.STACK_NAME }}
-          template: devops/infrastructure/cloudformation/single-instance.yml
+          template: devops/aws/cloudformation/single-instance.yml
           no-fail-on-empty-changeset: '1'
           parameter-overrides: 'KeyName=${{ env.KEY_NAME }}'
 
@@ -46,8 +48,8 @@ jobs:
       - name: Run playbook
         uses: dawidd6/action-ansible-playbook@v2
         with:
-          playbook: github-action-playbook.yml
-          directory: devops/infrastructure
+          playbook: create-joystream-node-ami-playbook.yml
+          directory: devops/aws
           requirements: requirements.yml
           key: ${{ secrets.SSH_PRIVATE_KEY }}
           inventory: |

+ 3 - 3
.github/workflows/joystream-node-docker.yml

@@ -71,7 +71,7 @@ jobs:
             platform_tag: 'arm'
             file: 'joystream-node-armv7.Dockerfile'
     env:
-      STACK_NAME: joystream-ga-docker-${{ github.run_number }}-${{ matrix.platform_tag }}
+      STACK_NAME: build-joystream-node-docker-ga-${{ github.run_number }}-${{ matrix.platform_tag }}
     steps:
       - name: Extract branch name
         shell: bash
@@ -120,7 +120,7 @@ jobs:
         id: deploy_stack
         with:
           name: ${{ env.STACK_NAME }}
-          template: devops/infrastructure/cloudformation/single-instance-docker.yml
+          template: devops/aws/cloudformation/single-instance-docker.yml
           no-fail-on-empty-changeset: '1'
           parameter-overrides: 'KeyName=${{ env.KEY_NAME }},EC2AMI=ami-00d1ab6b335f217cf,EC2InstanceType=t4g.xlarge'
         if: ${{ steps.compute_image_exists.outputs.image_exists == 1 }}
@@ -129,7 +129,7 @@ jobs:
         uses: dawidd6/action-ansible-playbook@v2
         with:
           playbook: build-arm64-playbook.yml
-          directory: devops/infrastructure
+          directory: devops/aws
           requirements: requirements.yml
           key: ${{ secrets.SSH_PRIVATE_KEY }}
           inventory: |

+ 0 - 0
devops/infrastructure/.gitignore → devops/aws/.gitignore


+ 7 - 1
devops/infrastructure/README.md → devops/aws/README.md

@@ -30,6 +30,12 @@ Copy and edit the file `deploy-config.sample.cfg` and update parameters like AWS
 Run the `deploy-infra.sh` script to deploy the infrastructure
 
 ```
-cd devops/infrastructure
+cd devops/aws
 ./deploy-infra.sh your-deploy-config.cfg
 ```
+
+# To tear down a network
+
+```
+./destroy-infra.sh your-deploy-config.cfg
+```

+ 0 - 0
devops/infrastructure/ansible.cfg → devops/aws/ansible.cfg


+ 0 - 0
devops/infrastructure/build-arm64-playbook.yml → devops/aws/build-arm64-playbook.yml


+ 0 - 0
devops/infrastructure/build-code.yml → devops/aws/build-code.yml


+ 0 - 0
devops/infrastructure/chain-spec-pioneer.yml → devops/aws/chain-spec-pioneer.yml


+ 9 - 0
devops/infrastructure/cloudformation/infrastructure.yml → devops/aws/cloudformation/infrastructure.yml

@@ -1,3 +1,9 @@
+# Deploy inftrastructure required to run a new joystream chain.
+# This is comprised of:
+#   - N validators
+#   - One RPC node
+#   - s3 bucket with a build of Pionner
+
 AWSTemplateFormatVersion: 2010-09-09
 
 Parameters:
@@ -116,6 +122,9 @@ Resources:
             # Update all packages
             apt-get update -y
 
+            # Prevent interactive prompts that would interrup the installation
+            export DEBIAN_FRONTEND=noninteractive
+
             # Install the updates except docker, to avoid interactive prompt which blocks the flow of the script
             apt-mark hold docker.io
             apt-get upgrade -y

+ 6 - 0
devops/infrastructure/cloudformation/single-instance-docker.yml → devops/aws/cloudformation/single-instance-docker.yml

@@ -1,3 +1,6 @@
+# Deploys and EC2 node with docker tools suitable for
+# building joystream node docker images
+
 AWSTemplateFormatVersion: 2010-09-09
 
 Parameters:
@@ -58,6 +61,9 @@ Resources:
             # Update all packages
             apt-get update -y
 
+            # Prevent interactive prompts that would interrup the installation
+            export DEBIAN_FRONTEND=noninteractive
+
             # Install the updates
             apt-get upgrade -y
 

+ 3 - 0
devops/infrastructure/cloudformation/single-instance.yml → devops/aws/cloudformation/single-instance.yml

@@ -59,6 +59,9 @@ Resources:
             # Update all packages
             apt-get update -y
 
+            # Prevent interactive prompts that would interrup the installation
+            export DEBIAN_FRONTEND=noninteractive
+
             # Install the updates
             apt-get upgrade -y
 

+ 0 - 0
devops/infrastructure/common.sh → devops/aws/common.sh


+ 0 - 0
devops/infrastructure/github-action-playbook.yml → devops/aws/create-joystream-node-ami-playbook.yml


+ 0 - 0
devops/infrastructure/deploy-config.sample.cfg → devops/aws/deploy-config.sample.cfg


+ 0 - 0
devops/infrastructure/deploy-infra.sh → devops/aws/deploy-infra.sh


+ 0 - 0
devops/infrastructure/deploy-single-node.sh → devops/aws/deploy-single-node.sh


+ 1 - 1
devops/infrastructure/delete-stack.sh → devops/aws/destroy-infra.sh

@@ -6,7 +6,7 @@ source common.sh
 
 if [ -z "$1" ]; then
   echo "ERROR: Configuration file not passed"
-  echo "Please use ./delete-stack.sh PATH/TO/CONFIG to run this script"
+  echo "Please use ./destroy-infra.sh PATH/TO/CONFIG to run this script"
   exit 1
 else
   echo "Using $1 file for config"

+ 0 - 0
devops/infrastructure/group_vars/all → devops/aws/group_vars/all


+ 0 - 0
devops/infrastructure/library/json_modify.py → devops/aws/library/json_modify.py


+ 0 - 0
devops/infrastructure/requirements.yml → devops/aws/requirements.yml


+ 0 - 0
devops/infrastructure/roles/admin/tasks/deploy-pioneer.yml → devops/aws/roles/admin/tasks/deploy-pioneer.yml


+ 0 - 0
devops/infrastructure/roles/admin/tasks/main.yml → devops/aws/roles/admin/tasks/main.yml


+ 0 - 0
devops/infrastructure/roles/common/tasks/chain-spec-node-keys.yml → devops/aws/roles/common/tasks/chain-spec-node-keys.yml


+ 0 - 0
devops/infrastructure/roles/common/tasks/get-code-git.yml → devops/aws/roles/common/tasks/get-code-git.yml


+ 0 - 0
devops/infrastructure/roles/common/tasks/get-code-local.yml → devops/aws/roles/common/tasks/get-code-local.yml


+ 0 - 0
devops/infrastructure/roles/common/tasks/run-setup-build.yml → devops/aws/roles/common/tasks/run-setup-build.yml


+ 0 - 0
devops/infrastructure/roles/node/templates/joystream-node.service.j2 → devops/aws/roles/node/templates/joystream-node.service.j2


+ 0 - 0
devops/infrastructure/roles/rpc/tasks/main.yml → devops/aws/roles/rpc/tasks/main.yml


+ 0 - 0
devops/infrastructure/roles/rpc/templates/Caddyfile.j2 → devops/aws/roles/rpc/templates/Caddyfile.j2


+ 0 - 0
devops/infrastructure/roles/rpc/templates/joystream-node.service.j2 → devops/aws/roles/rpc/templates/joystream-node.service.j2


+ 0 - 0
devops/infrastructure/roles/validators/tasks/main.yml → devops/aws/roles/validators/tasks/main.yml


+ 0 - 0
devops/infrastructure/roles/validators/templates/joystream-node.service.j2 → devops/aws/roles/validators/templates/joystream-node.service.j2


+ 0 - 0
devops/infrastructure/setup-admin.yml → devops/aws/setup-admin.yml


+ 0 - 0
devops/infrastructure/single-node-playbook.yml → devops/aws/single-node-playbook.yml


+ 0 - 0
devops/infrastructure/node-network/.gitignore → devops/kubernetes/node-network/.gitignore


+ 0 - 0
devops/infrastructure/node-network/Pulumi.yaml → devops/kubernetes/node-network/Pulumi.yaml


+ 0 - 0
devops/infrastructure/node-network/README.md → devops/kubernetes/node-network/README.md


+ 0 - 0
devops/infrastructure/node-network/configMap.ts → devops/kubernetes/node-network/configMap.ts


+ 0 - 0
devops/infrastructure/node-network/index.ts → devops/kubernetes/node-network/index.ts


+ 0 - 0
devops/infrastructure/node-network/json_modify.py → devops/kubernetes/node-network/json_modify.py


+ 0 - 0
devops/infrastructure/node-network/nfsVolume.ts → devops/kubernetes/node-network/nfsVolume.ts


+ 0 - 0
devops/infrastructure/node-network/package.json → devops/kubernetes/node-network/package.json


+ 0 - 0
devops/infrastructure/node-network/tsconfig.json → devops/kubernetes/node-network/tsconfig.json


+ 0 - 0
devops/infrastructure/node-network/utils.ts → devops/kubernetes/node-network/utils.ts


+ 0 - 0
devops/infrastructure/node-network/validator.ts → devops/kubernetes/node-network/validator.ts


+ 0 - 0
devops/infrastructure/pulumi-common/caddy.ts → devops/kubernetes/pulumi-common/caddy.ts


+ 0 - 0
devops/infrastructure/pulumi-common/index.ts → devops/kubernetes/pulumi-common/index.ts


+ 0 - 0
devops/infrastructure/pulumi-common/package.json → devops/kubernetes/pulumi-common/package.json


+ 0 - 0
devops/infrastructure/pulumi-common/tsconfig.json → devops/kubernetes/pulumi-common/tsconfig.json


+ 0 - 0
devops/infrastructure/query-node/.gitignore → devops/kubernetes/query-node/.gitignore


+ 0 - 0
devops/infrastructure/query-node/Pulumi.yaml → devops/kubernetes/query-node/Pulumi.yaml


+ 0 - 0
devops/infrastructure/query-node/README.md → devops/kubernetes/query-node/README.md


+ 0 - 0
devops/infrastructure/query-node/configMap.ts → devops/kubernetes/query-node/configMap.ts


+ 0 - 0
devops/infrastructure/query-node/index.ts → devops/kubernetes/query-node/index.ts


+ 31 - 0
devops/kubernetes/query-node/kubeconfig

@@ -0,0 +1,31 @@
+apiVersion: v1
+clusters:
+- cluster:
+    certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM1ekNDQWMrZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJeE1UQXlNakV6TkRreU9Wb1hEVE14TVRBeU1ERXpORGt5T1Zvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBSjJvCm0xcmpMaEs5eEN1WVRq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mpjclBkQklQQ3kyQQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
+    server: https://450F306AE798F0057C49C428A8BE608A.gr7.us-east-1.eks.amazonaws.com
+  name: kubernetes
+contexts:
+- context:
+    cluster: kubernetes
+    namespace: query-node-ifgoohih
+    user: aws
+  name: aws
+current-context: aws
+kind: Config
+preferences: {}
+users:
+- name: aws
+  user:
+    exec:
+      apiVersion: client.authentication.k8s.io/v1alpha1
+      args:
+      - eks
+      - get-token
+      - --cluster-name
+      - eksctl-query-node-eksCluster-7e1b8b4
+      command: aws
+      env:
+      - name: AWS_PROFILE
+        value: joystream-user
+      interactiveMode: IfAvailable
+      provideClusterInfo: false

+ 0 - 0
devops/infrastructure/query-node/package.json → devops/kubernetes/query-node/package.json


+ 0 - 0
devops/infrastructure/query-node/s3Helpers.ts → devops/kubernetes/query-node/s3Helpers.ts


+ 0 - 0
devops/infrastructure/query-node/tsconfig.json → devops/kubernetes/query-node/tsconfig.json


+ 0 - 0
devops/infrastructure/storage-node/.gitignore → devops/kubernetes/storage-node/.gitignore


+ 0 - 0
devops/infrastructure/storage-node/Pulumi.yaml → devops/kubernetes/storage-node/Pulumi.yaml


+ 0 - 0
devops/infrastructure/storage-node/README.md → devops/kubernetes/storage-node/README.md


+ 0 - 0
devops/infrastructure/storage-node/index.ts → devops/kubernetes/storage-node/index.ts


+ 0 - 0
devops/infrastructure/storage-node/package.json → devops/kubernetes/storage-node/package.json


+ 0 - 0
devops/infrastructure/storage-node/tsconfig.json → devops/kubernetes/storage-node/tsconfig.json


+ 2 - 0
setup.sh

@@ -3,6 +3,8 @@
 set -e
 
 if [[ "$OSTYPE" == "linux-gnu" ]]; then
+    # Prevent interactive prompts that would interrup the installation
+    export DEBIAN_FRONTEND=noninteractive
     # code build tools
     sudo apt-get update
     sudo apt-get install -y coreutils clang llvm jq curl gcc xz-utils sudo pkg-config unzip libc6-dev make libssl-dev python