Anuj Bansal c5249503a3 Change graphql caddy endpoint, update README il y a 3 ans
..
.gitignore 79d139c83c Add caddy wrapper, export hostname il y a 3 ans
Pulumi.yaml 79d139c83c Add caddy wrapper, export hostname il y a 3 ans
README.md c5249503a3 Change graphql caddy endpoint, update README il y a 3 ans
caddy.ts c5249503a3 Change graphql caddy endpoint, update README il y a 3 ans
configMap.ts dd0c0b8a38 Create modular configmap, add option to run on local and aws il y a 3 ans
index.ts 79d139c83c Add caddy wrapper, export hostname il y a 3 ans
package.json c0c07296f9 Upload boostrap data files to S3, add init container il y a 3 ans
s3Helpers.ts c0c07296f9 Upload boostrap data files to S3, add init container il y a 3 ans
tsconfig.json eb74447c2c Add database and redis containers for query node k8s il y a 3 ans

README.md

Query Node automated deployment

Deploys an EKS Kubernetes cluster with query node

Deploying the App

To deploy your infrastructure, follow the below steps.

Prerequisites

  1. Install Pulumi
  2. Install Node.js
  3. Install a package manager for Node.js, such as npm or Yarn.
  4. Configure AWS Credentials
  5. Optional (for debugging): Install kubectl

Steps

After cloning this repo, from this working directory, run these commands:

  1. Install the required Node.js packages:

This installs the dependent packages needed for our Pulumi program.

   $ npm install
  1. Create a new stack, which is an isolated deployment target for this example:

This will initialize the Pulumi program in TypeScript.

   $ pulumi stack init
  1. Set the required configuration variables in Pulumi.<stack>.yaml

    $ pulumi config set-all --plaintext aws:region=us-east-1 --plaintext aws:profile=joystream-user \
    --plaintext workersFilePath=<PATH> --plaintext membersFilePath=<PATH> --plaintext isMinikube=true
    

If you want to build the stack on AWS set the isMinikube config to false

   $ puluim config set isMinikube false
  1. Create a .env file in this directory (cp ../../../.env ./.env) and set the database and other variables in it

Make sure to set GRAPHQL_SERVER_PORT=4001

  1. Stand up the Kubernetes cluster:

Running pulumi up -y will deploy the EKS cluster. Note, provisioning a new EKS cluster takes between 10-15 minutes.

  1. Once the stack is up and running, we will modify the Caddy config to get SSL certificate for the load balancer

Modify the config variable isLoadBalancerReady

   $ pulumi config set isLoadBalancerReady true

Run pulumi up -y to update the Caddy config

  1. You can now access the endpoints using pulumi stack output endpoint1 or pulumi stack output endpoint2

The GraphQl server is accessible at https://<ENDPOINT>/server/graphql and indexer at https://<ENDPOINT>/indexer/graphql

  1. Access the Kubernetes Cluster using kubectl

To access your new Kubernetes cluster using kubectl, we need to set up the kubeconfig file and download kubectl. We can leverage the Pulumi stack output in the CLI, as Pulumi facilitates exporting these objects for us.

   $ pulumi stack output kubeconfig --show-secrets > kubeconfig
   $ export KUBECONFIG=$PWD/kubeconfig
   $ kubectl get nodes

We can also use the stack output to query the cluster for our newly created Deployment:

   $ kubectl get deployment $(pulumi stack output deploymentName) --namespace=$(pulumi stack output namespaceName)
   $ kubectl get service $(pulumi stack output serviceName) --namespace=$(pulumi stack output namespaceName)

To get logs

   $ kubectl config set-context --current --namespace=$(pulumi stack output namespaceName)
   $ kubectl get pods
   $ kubectl logs <PODNAME> --all-containers

To see complete pulumi stack output

   $ pulumi stack output

To execute a command

   $ kubectl exec --stdin --tty <PODNAME> -c colossus -- /bin/bash
  1. Once you've finished experimenting, tear down your stack's resources by destroying and removing it:

    $ pulumi destroy --yes
    $ pulumi stack rm --yes