# High Availability Demo
This demo helps you explore TiDB's high availability features. You will setup a TiDB cluster cluster in EKS with one command, use [ChaosMesh](https://chaos-mesh.org/) to inject errors, and see how TiDB's high availability work out with a django/python application.

# Instructions
## 1. Spin up TiDB cluster
Follow the commands below to spin up test cluster
```bash
# checkout github repository 
git clone https://github.com/pingcap/tisample.git
# go to the tiup tool directory
cd tisample/tidb-demo-aws/tioperator
# run terraform commands to spin up AWS resources
terraform init
terraform apply
```

### SSH to the jump server
You should see similar results as below after successfully applied the terraform
```bash
Apply complete! Resources: 70 added, 0 changed, 0 destroyed.

Outputs:

jump_ssh_login = "ssh -i ~/.ssh/tidb_demo centos@18.136.105.205"
mysql_command = "mysql -h a82ad27e9a09e436590bf730f59cdc3a-397e8113b17bc78e.elb.ap-southeast-1.amazonaws.com -P 4000 -u root"
tidb_dashboard_url = "http://ac12873c84cbe4c9380beb1ac65373af-07dd3695de697951.elb.ap-southeast-1.amazonaws.com/dashboard"
tidb_grafana_url = "http://ac99ba5d446014a14ba3b4d7940b61d0-cec0ff271e6863e1.elb.ap-southeast-1.amazonaws.com:3000"
```
Use jump_ssh_login to SSH to the jump server 
```bash
# login to jump server
# NOTE: you can copy paste the value of "jump_ssh_login" from the terraform apply output 
ssh -i ~/.ssh/tidb_demo centos@<jump server address>
```

## 2. Setup ChaosMesh
```bash
# run the following script in the jump server
cd
. demos/high_availability/files_k8s/install_chaosmesh.sh
```
Checkout the chaosmesh_dashboard_url output by the script in your browser. We will use this dashboard to view error injections

## 3. Setup Django/Python application
TODO

## 4. Run high availabiltiy tests
TODO

## 5. Cleanup
```bash
# go back to the local machine, and go to the tioperator dir
# run destroy
# NOTE: if the destory command fails, please just rerun the command, for more details, please check the "Known Issues" section
terraform destroy
```


