THORChain 백서

THORChain

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 19쪽 중 12쪽

of setup.** **Windows should choose either:** 1. **Deploy a THORNode from a Linux VPS.** 2. **Use Windows Subsystem for Linux -** [**https://docs.microsoft.com/en-us/windows/wsl/about**](https://docs.microsoft.com/en-us/windows/wsl/about)\*\*\*\* {% endhint %} ## **Steps** Firstly, clone and enter the [cluster-launcher repository](https://gitlab.com/thorchain/devops/cluster-launcher)**.** All commands in this section are to be run inside this repo. ``` git clone https://gitlab.com/thorchain/devops/cluster-launcher cd cluster-launcher ``` Then install the [terraform CLI](https://www.terraform.io): {% tabs %} {% tab title="LINUX/MAC" %} Install Terraform: ```bash brew install terraform ``` {% endtab %} {% endtabs %} #### **hcloud CLI** The [hcloud CLI](https://github.com/hetznercloud/cli#installation) allows you to manage your hcloud services. {% tabs %} {% tab title="LINUX/MAC" %} Use the package manager [homebrew](https://formulae.brew.sh/) to install the hcloud CLI. ```bash brew install hcloud hcloud context create <project_name> ``` {% endtab %} {% endtabs %} {% hint style="warning" %} You will be asked for you Personal Access Token with read/write priveleges (retrieve from API Panel from the hcloud web console.) **API -> Tokens/Keys -> Create Token.** Make sure you handle your secrets securely! {% endhint %} #### Kubernetes Control Tool You must install and configure the Kubernetes CLI tool (**kubectl**). **\*\*To install** kubectl\*\* , follow [these instructions](https://kubernetes.io/docs/tasks/tools/install-kubectl/), or choose a package manager based on your operating system. {% tabs %} {% tab title="LINUX/MAC" %} Use the package manager [homebrew](https://formulae.brew.sh/) to install **kubectl**. ```bash brew install kubernetes-cli ``` {% endtab %} {% endtabs %} #### **wget && jq** You also need **wget** and **jq**, follow [these instructions](https://www.gnu.org/software/wget/), or choose a package manager based on your operating system. {% tabs %} {% tab title="LINUX/MAC" %} Use the package manager [homebrew](https://formulae.brew.sh/) to install **wget** and **jq** *Note: You most likely have these installed already.* ```bash brew install wget brew install jq ``` {% endtab %} {% endtabs %} ## **Environment** Initialize the git submodule. ```bash git submodule update --init ``` Use `direnv`, `venv` or whatever you prefer to manage a python environment inside the hcloud folder. ```bash # Optional (cd hcloud && direnv allow) # Optional (cd hcloud && virtualenv -p python3 venv) ``` Install dependencies required by Python and Ansible Galaxy. ```bash (cd hcloud && pip install -r ansible/requirements.txt) (cd hcloud && ansible-galaxy install -r ansible/requirements.yml) ``` ## **Deploy Kubernetes Cluster** Use the commands below to deploy an hcloud cluster: ```bash make hcloud ``` During the deploy, you will be asked to enter information about your cluster: ```bash var.name The base name used for all resources Enter a value: tc-k8s var.token Hetzner Cloud API token Enter a value: <secret> var.user_name The admin user name for the nodes Enter a value: admin ``` * Name * Token * Confirm `yes` {% hint style="info" %} Deploying a cluster takes \~15 minutes {% endhint %} ### Quotas If necessary, request a quota increase [here](https://console.hetzner.cloud/limits). ## CONFIGURE Now that you've provisioned your hcloud cluster, you need to configure **kubectl**. Customize the following command with your cluster name and resource group. It will get the access credentials for your cluster and automatically configure kubectl. ```bash (cd hcloud && scp $(terraform output -raw hcloud_config) ~/.kube/config-hcloud) # Merge it and set current context KUBECONFIG=~/.kube/config:~/.kube/config-hcloud kubectl config view --flatten > ~/.kube/tmpcfg && mv -f ~/.kube/tmpcfg ~/.kube/config && kubectl config use-context $(kubectl config current-context --kubeconfig=$HOME/.kube/config-hcloud) kubectl version ``` You are now ready to deploy a THORNode. # Setup - Digital Ocean Setting up a Kubernetes Cluster with Digital Ocean (DO) ## **Deploy a Kubernetes cluster in DO using DOKS service.** ### **Requirements** 1. DO account 2. `doctl` and DO credentials configured 3. `kubectl` 4. `homebrew` {% hint style="warning" %} **LINUX/MAC is the preferred method of setup.** **Windows should choose either:** 1. **Deploy a THORNode from a Linux VPS.** 2. **Use Windows Subsystem for Linux -** [**https://docs.microsoft.com/en-us/windows/wsl/about**](https://docs.microsoft.com/en-us/windows/wsl/about) {% endhint %} ## **Steps** Firstly, clone and enter the [cluster-launcher repository](https://gitlab.com/thorchain/devops/cluster-launcher)**.** All commands in this section are to be run inside this repo. ``` git clone https://gitlab.com/thorchain/devops/cluster-launcher cd cluster-launcher ``` Then install the [terraform CLI](https://www.terraform.io): {% tabs %} {% tab title="LINUX/MAC" %} Install Terraform: ``` brew install terraform ``` {% endtab %} {% endtabs %} #### **DOCTL** The [Digital Ocean Control tool](https://www.digitalocean.com/docs/apis-clis/doctl/how-to/install/) allows you to manage your DO services. {% tabs %} {% tab title="LINUX/MAC" %} Use the package manager [homebrew](https://formulae.brew.sh/) to install the `doctl`. ``` brew install doctl doctl auth init --context <NAME> doctl auth switch --context <NAME> doctl account get ``` {% endtab %} {% endtabs %} {% hint style="warning" %} You will be asked for a Personal Access Token with read/write priveleges (retrieve from the API Panel in the Digital Ocean web console.) **API -> Tokens/Keys -> Create Token.** Make sure you handle your secrets securely! You will need this token twice more for setup and if you navigate away from the API web console it will not be displayed again. {% endhint %} #### Kubernetes Control Tool You must install and configure the Kubernetes CLI tool (`kubectl`). **To install kubectl** , follow [these instructions](https://kubernetes.io/docs/tasks/tools/install-kubectl/), or choose a package manager based on your operating system. {% tabs %} {% tab title="LINUX/MAC" %} Use the package manager [homebrew](https://formulae.brew.sh/) to install **kubectl**. ``` brew install kubernetes-cli ``` {% endtab %} {% endtabs %} {% hint style="warning" %} **DO Droplet Limit** You will need to increase your Droplet Limit if you get an error like this: ``` Error: Error creating Kubernetes cluster: POST https://api.digitalocean.com/v2/kubernetes/clusters: 422 (request "8b639077-b8d3-4913-b3ec-8e70283dea49") validation error: worker_node_pool_specs[0].invalid droplet size ``` On the Digital Ocean web console (Settings > Team > Droplet Limit) you will be able to request the `Droplet Limit` be increased. 10 Droplets is the default limit, request 25 to begin with. {% endhint %} {% hint style="info" %} **Check the versions of `kubectl` that are supported by DO** ``` doctl kubernetes options versions ``` Make sure that you have installed a version of `kubectl` that is supported by DO. {% endhint %} #### **wget && jq** You also need **wget** and **jq**, follow [these instructions](https://www.gnu.org/software/wget/), or choose a package manager based on your operating system. {% tabs %} {% tab title="LINUX/MAC" %} Use the package manager [homebrew](https://formulae.brew.sh/) to install **wget** and **jq** *Note: You most likely have these installed already.* ``` brew install wget brew install jq ``` {% endtab %} {% endtabs %} ## **Deploy Kubernetes Cluster** Use the commands below to deploy a DOKS cluster: ``` make do ``` During the deploy, you will be asked to enter information about your cluster: ![](https://3337783180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfvaTNxU33ciP7UstKtwU%2Fuploads%2Fgit-blob-60c8851fb327b6f2f773abae0f6c81fa7964f368%2Fimage%20\(20\)%20\(1\).png?alt=media) * Name * DO Region -- see valid [List of Regions](https://www.digitalocean.com/docs/platform/availability-matrix/#other-product-availability) (**use lower-case**) * Confirm `yes` ![Kubernetes Availability (note, use lower-case in the terminal)](https://3337783180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfvaTNxU33ciP7UstKtwU%2Fuploads%2Fgit-blob-0b9ac8cad4af0d56c43244abe9228cd79ff62030%2Fimage%20\(26\).png?alt=media) Final success message: `Apply complete! Resources: 2 added, 0 changed, 0 destroyed.` {% hint style="info" %} Deploying a cluster takes \~10 minutes {% endhint %} ## CONFIGURE Now that you've provisioned your DOKS cluster, you need to configure **kubectl**. Customize the following command with your cluster name and region. ``` doctl kubernetes cluster kubeconfig save <use_your_cluster_name> kubectl version ``` If successful, you will see: ``` Notice: Adding cluster credentials to kubeconfig file found in "/home/user/.kube/config" Notice: Setting current-context to do-<region_name>-<cluster_name> ``` Test this configuration, ``` $ kubectl version Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.6", GitCommit:"dff82dc0de47299ab66c83c626e08b245ab19037", GitTreeState:"clean", BuildDate:"2020-07-16T06:30:04Z", GoVersion:"go1.14.5", Compiler:"gc", Platform:"linux/amd64"} Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.6", GitCommit:"dff82dc0de47299ab66c83c626e08b245ab19037", GitTreeState:"clean", BuildDate:"2020-07-15T16:51:04Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"} ``` To verify, run this, and check the status is "Ready": ``` kubectl get nodes NAME STATUS ROLES AGE VERSION <cluster_name>-pool-5xhc1 READY <none> 6m v1.18.6 ``` You are now ready to deploy a THORNode. # Setup - AWS Setting up a Kubernetes Cluster with AWS ## **Deploy a Kubernetes cluster in AWS using EKS service.** ### **Requirements** 1. AWS account 2. CLI and AWS credentials configured 3. AWS IAM Authenticator 4. `kubectl` 5. `wget` (required for EKS module) {% hint style="warning" %} **LINUX/MAC is the preferred method of setup.** **Windows should choose either:** 1. **Deploy a THORNode from a Linux VPS.** 2. **Use Windows Subsystem for Linux -** [**https://docs.microsoft.com/en-us/windows/wsl/about**](https://docs.microsoft.com/en-us/windows/wsl/about)\*\*\*\* {% endhint %} ## **Steps** Firstly, clone and enter the [cluster-launcher repository](https://gitlab.com/thorchain/devops/cluster-launcher)**.** All commands in this section are to be run inside this repo. ``` git clone https://gitlab.com/thorchain/devops/cluster-launcher cd cluster-launcher ``` Then install the [terraform CLI](https://www.terraform.io): {% tabs %} {% tab title="LINUX/MAC" %} Install Terraform: ``` brew install terraform ``` {% endtab %} {% endtabs %} #### **AWS CLI** In order for Terraform to run operations on your behalf, you must install and configure the AWS CLI tool. \*\*\*\*To install the AWS CLI, follow [these instructions](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-mac.html), or choose a package manager based on your operating system. {% tabs %} {% tab title="LINUX/MAC" %} Use the package manager [homebrew](https://formulae.brew.sh/) to install the AWS CLI. ``` brew install awscli aws configure ``` {% endtab %} {% endtabs %} {% hint style="warning" %} You will be asked for you AWS access credentials (retrieve from AWS IAM from the AWS web console.) **IAM -> User -> Security Credentials -> Create Access Key.** Make sure you handle your secrets securely! {% endhint %} #### **AWS IAM Authenticator** You also must install and configure the **AWS IAM Authenticator** tool. \*\*\*\*To install, follow [these instructions](https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html), or choose a package manager based on your operating system. {% tabs %} {% tab title="LINUX/MAC" %} Use the package manager [homebrew](https://formulae.brew.sh/) to install the **AWS IAM Authenticator**. ```bash brew install aws-iam-authenticator ``` {% endtab %} {% endtabs %} #### Kubernetes Control Tool You must install and configure the Kubernetes CLI tool (**kubectl**). \*\*\*\*To install **kubectl** , follow [these instructions](https://kubernetes.io/docs/tasks/tools/install-kubectl/), or choose a package manager based on your operating system. {% tabs %} {% tab title="LINUX/MAC" %} Use the package manager [homebrew](https://formulae.brew.sh/) to install **kubectl**. ``` brew install kubernetes-cli ``` {% endtab %} {% endtabs %} #### **wget && jq** You also need **wget** and **jq**, follow [these instructions](https://www.gnu.org/software/wget/), or choose a package manager based on your operating system. {% tabs %} {% tab title="LINUX/MAC" %} Use the package manager [homebrew](https://formulae.brew.sh/) to install **wget** and **jq**\ \&#xNAN;*Note: You most likely have these installed already.* ``` brew install wget brew install jq ``` {% endtab %} {% endtabs %} ## **Deploy Kubernetes Cluster** Use the commands below to deploy an AWS EKS cluster. You can run the make command that automates those command for you like this: ``` make aws ``` During the deploy, you will be asked to enter information about your cluster: ![](https://3337783180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfvaTNxU33ciP7UstKtwU%2Fuploads%2Fgit-blob-60c8851fb327b6f2f773abae0f6c81fa7964f368%2Fimage%20\(20\)%20\(1\).png?alt=media) * Name * AWS Region -- see valid [List of Regions](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints) * Confirm `yes` ![Regions](https://3337783180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfvaTNxU33ciP7UstKtwU%2Fuploads%2Fgit-blob-52ead67f0a5e7b4cea0f321dd3fe0f06ef9c3d91%2Fimage%20\(25\).png?alt=media) ![Note: AWS EKS is not available in some regions](https://3337783180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfvaTNxU33ciP7UstKtwU%2Fuploads%2Fgit-blob-b1c1413147a5e9b714a6269c7ab8bd898ea442f7%2Fimage%20\(21\).png?alt=media) Or manually: ``` cd aws/ terraform init terraform plan # to see the plan terraform apply ``` Final success message: `Apply complete! Resources: 30 added, 0 changed, 0 destroyed.` {% hint style="info" %} If you are a **returning** node operator and you wish to use the same node name, the Cloudwatch log files from your previous session will block this step. You need to manually delete the logs from your console: **Cloudwatch / Cloudwatch Logs / Log Groups -> "delete"** {% endhint %} {% hint style="info" %} Deploying a cluster takes \~10 minutes {% endhint %} ## CONFIGURE kubectl This is done automatically during provisioning. To configure authentication from the command line, use the following command. It will get the access credentials for your cluster and automatically configure kubectl in case you need to manually reconfigure kubectl. ``` make kubeconfig-aws ``` Or get your kubeconfig file manually: ``` (cd aws && aws eks --region $(terraform output -raw region) update-kubeconfig --name $(terraform output -raw cluster_name)) ``` To verify, run this, and check the status is "Ready": ``` kubectl version kubectl cluster-info kubectl get nodes ``` You are now ready to deploy a THORNode. ### BACKUPS (OPTIONAL) Once your node is running, use the following command to automatically backup the Persistent Volumes for your Kubernetes cluster. This may help in recovering your node in the event of a disaster. Enable backups: ``` make aws-backups ``` Disable backups: ``` make aws-destroy-backups ``` # Deploying Deploying a THORNode and its associated services. ## **Deploy THORNode services** Now you have a Kubernetes cluster ready to use, you can install the THORNode services. {% hint style="info" %} Helm charts are the defacto and currently easiest and simple way to package and deploy Kubernetes application. The team created different Helm charts to help to deploy all the necessary services. Please retrieve the source files from the Git repository here to follow the instructions below: [**https://gitlab.com/thorchain/devops/node-launcher**](https://gitlab.com/thorchain/devops/node-launcher) {% endhint %} ### Requirements * Running Kubernetes cluster * Kubectl configured, ready and connected to running cluster {% hint style="info" %} If you came here from the Setup page, you are already good to go. {% endhint %} ## Steps Clone the `node-launcher` repo. All commands in this section are to be run inside of this repo. ```bash git clone https://gitlab.com/thorchain/devops/node-launcher cd node-launcher git checkout master ``` ### Install Helm 3 Install Helm 3 if not already available on your current machine: ```bash make helm make helm-plugins ``` ### Tools {% tabs %} {% tab title="Deploy" %} To deploy all tools, metrics, logs management, Kubernetes Dashboard, run the command below. ```bash make tools ``` {% endtab %} {% tab title="Destroy" %} To destroy all those resources run the command below. ```bash make destroy-tools ``` {% endtab %} {% endtabs %} You need to give the deployment a namespace name, `thorchain` is used in the example below. If you are successful, you will see the following message: ![](https://3337783180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfvaTNxU33ciP7UstKtwU%2Fuploads%2Fgit-blob-9aa73b99c5e22b401e43dec7120b368f4eff2d05%2Fimage%20\(14\).png?alt=media) If there are any errors, they are typically fixed by running the command again. {% hint style="success" %} `make help` will list all commands available. See [here](https://gitlab.com/thorchain/devops/node-launcher/-/blob/master/README.md) for more information. {% endhint %} ## Deploy THORNode It is important to deploy the tools first before deploying the THORNode services as some services will have metrics configuration that would fail and stop the THORNode deployment. {% hint style="info" %} Testnet no longer exists, only mainnet THORNodes can be created. {% endhint %} You have multiple commands available to deploy different configurations of THORNode. The commands deploy the umbrella chart `thornode-stack` in the background in the Kubernetes namespace `thornode` by default. ```bash NET=mainnet TYPE=<type> NAME=<namepsace name> make install e.g. NET=mainnet TYPE=validator NAME=thornode make install ``` {% hint style="info" %} If you are intending to run all chain clients, bond in & earn rewards, you want to choose "Validator". Select FullNode if you only want to run THORNode and Midgard. {% endhint %} {% hint style="info" %} Deploying a THORNode will take 1 day for every 3 months of ledger history, since it will validate every block. THORNodes are "full nodes", not light clients. {% endhint %} If successful, you will see the following: ![](https://3337783180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfvaTNxU33ciP7UstKtwU%2Fuploads%2Fgit-blob-9479f675e0ca32bcb4c0cbe6a89bcd3f68c46db2%2Fimage%20\(15\).png?alt=media) You are now ready to join the network: {% content-ref url="/pages/cPfGgXpXBkXVvwyZMbhT" %} [Joining](/thornodes/joining) {% endcontent-ref %} ### Debugging {% hint style="info" %} Set `thornode` to be your default namespace so you don't need to type `-n thornode` each time: `kubectl config set-context --current --namespace=thornode` {% endhint %} Use the following useful commands to view and debug accordingly. You should see everything running and active. Logs can be retrieved to find errors: ```bash kubectl get pods -n thornode kubectl get pods --all-namespaces kubectl logs -f <pod> -n thornode ``` Kubernetes should automatically restart any service, but you can force a restart by running: ```bash kubectl delete pod <pod> -n thornode ``` {% hint style="warning" %} Note, to expedite syncing external chains, it is feasible to continually delet
프로젝트로 돌아가기