# Cluster Prober

Cluster Prober probe a existing TiDB cluster.

Supported Methods:

* `database`: Connect to the TiDB and execute SQL to probe. For example, check endpoints are active.
* `infra`: Get the cluster CR from infra apiserver to probe. For example, check the cluster status is existing and normal.
* `platform`: Get the cluster from platform to probe. For example, check the cluster is existing and normal.

## Setup

### Database Prober

#### Probe via public endpoint

1. Allow the cluster-prober to connect the database.

   1. Find public IP addresses where the cluster-prober deployed.
   
   2. Add all public IP addresses to a traffic filter for the target TiDB cluster.

2. Provide the user and password of the database to the cluster-prober.

   1. Mount a `Secret` for the cluster-prober to provide the user and password.

3. Set `probers.database` fields in the config.
   
   ```yaml
   target:
     clusterID: "90411"
   probers:
     database:
       addrs:
       - "tidb.dpuvqeht7n0.clusters.dev.tidb-cloud.com:4000" # host:port
       userFile: /etc/cluster-prober/secrets/dbUser          # the file to read the user
       passwordFile: /etc/cluster-prober/secrets/dbPassword  # the file to read the password
   ```

#### Probe via private link

1. Allow the cluster-prober to connect the database.

   1. Find the VPC ID and Subnet IDs where the cluster-prober deployed.

   2. [**Setup a private endpoint**](https://docs.pingcap.com/tidbcloud/set-up-private-endpoint-connections#step-2-check-the-service-endpoint-region).
      
2. Provide the user and password of the database to the cluster-prober.

   1. Mount a `Secret` for the cluster-prober to provide the user and password.

3. Set `probers.database` fields in the config.
   
   ```yaml
   target:
     clusterID: "90411"
     projectID: "43562"
   probers:
     database:
       addrs:
       - "privatelink-tidb.dpuvqeht7n0.clusters.dev.tidb-cloud.com:4000:4000" # host:port
       userFile: /etc/cluster-prober/secrets/dbUser          # the file to read the user
       passwordFile: /etc/cluster-prober/secrets/dbPassword  # the file to read the password
   ```

### Infra Prober

1. Set the `infraKubeConfig` and `probers.infra` fields in the config. 
   
   ```yaml
   infraKubeConfig: /.kube/config  # the kubeconfig to access the infra apiserver
   target:
     clusterID: "90411"
     projectID: "43562"
     clusterName: "90411"  # the cluster cr name
     clusterNamespace: nightly-ms-43562  # the cluster cr namespace
   probers:
     infra: {}
   ```

### Platform Prober

1. Provide a API key pair to the cluster-prober.

   1. Create a API key pair in the [**TiDB Cloud**](https://docs.pingcap.com/tidbcloud/api/v1beta).

   2. Mount a `Secret` for the cluster-prober to provide the key pair.

2. Set `probers.platform` fields in the config.
   
   ```yaml
   target:
     clusterID: "90411"
     projectID: "43562"
   probers:
     platform:
       publicKeyFile: "/etc/cluster-prober/secrets/public.key"   # the file to read the public key
       privateKeyFile: "/etc/cluster-prober/secrets/private.key" # the file to read the private key
   ```
