# Debug dataplane TiDB cluster

## Build the docker image

`docker build -t debug .`

## Debug a target TiDB cluster

### Dev and Staging

For dev and staging, no bastion is required. Login locally and mount the `$HOME/.aws` and `$HOME/.config/gcloud` into debug container

Prepare infra-apiserver kubeconfig and gardener kubeconfig

1. Login aws sso: `aws sso login --profile dbaas-dev`
2. Login gcloud: `gcloud auth login`
3. Run the debug container: `./debug.sh -clusterId=123 -projectId=456`
4. Access the cluster via the helper script: `/pd-ctl.sh`, `/tikv-ctl.sh` and `/ssh-connect.sh`

### Prod

Prepare infra-apiserver kubeconfig, gardener kubeconfig and gcp-oidc-credentials.json in /home/ssm-user/oncall-config

1. Login awscli sso: `aws sso login --profile prod`
2. Login to bastion machine: `aws ssm start-session --target i-0839bafc81b8fa697 --profile prod`
3. Run the debug docker container: `$HOME/bin/debug-prod.sh -clusterId=123 -projectId=456`
4. Access the cluster via helper script: `/pd-ctl.sh`, `/tikv-ctl.sh` and `/ssh-connect.sh`