## Module 2: Deploy A TiDB Cluster On Amazon EKS Using TiDB Operator

### Step 1. View the TidbCluster manifest

+ View the provided TidbCluster manifest `solution-tidb-cluster.yaml`, which defines the TiDB cluster to be deployed by TiDB Operator on Amazon EKS. The TiDB Operator has already been installed during the lab bootstrap.

   ```bash
   cat solution-tidb-cluster.yaml
   ```

   ```output
   apiVersion: pingcap.com/v1alpha1
   kind: TidbCluster
   metadata:
     name: tidb-demo
     namespace: tidb-cluster
   spec:
     version: v8.1.1
     tidb:
       service:
         type: LoadBalancer
         annotations:
           service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
           service.beta.kubernetes.io/aws-load-balancer-scheme: "internal"
   ```

+ On EKS, TiDB is exposed via an internal Network Load Balancer (NLB), accessible from the bastion host in the same VPC.

### Step 2. Verify TiDB Operator is running

+ Check that the TiDB Operator is installed and its pods are running:

   ```bash
   kubectl get pods -n tidb-admin
   ```

   ```output
   NAME                                      READY   STATUS    RESTARTS   AGE
   tidb-operator-xxxxx                       1/1     Running   0          5m
   tidb-scheduler-xxxxx                      1/1     Running   0          5m
   ```

### Step 3. Deploy the TiDB cluster

+ The TiDB cluster may have already been deployed during the lab bootstrap. If not, or if you want to redeploy, apply the TidbCluster manifest:

   ```bash
   kubectl apply -f solution-tidb-cluster.yaml
   ```

   ```output
   tidbcluster.pingcap.com/tidb-demo configured
   ```

+ Wait for the TiDB cluster to become ready. This typically takes 3-5 minutes:

   ```bash
   kubectl wait --for=condition=Ready tidbcluster/tidb-demo -n tidb-cluster --timeout=600s
   ```

   ```output
   tidbcluster.pingcap.com/tidb-demo condition met
   ```
