Deploy a TiDB Cluster
- Objective: Learn to deploy a TiDB cluster on AWS (with Kubernetes)
- background knowledge of TiDB components
- AWS account
- Optionality: Required
- Estimated time: 40min - 60min
Install TiDB Cluster
Prepare yaml file
Following command copies the pre-defined
db.yaml.example file and replace
CLUSTER_NAME with new cluster name
Note: If you have changed the TiDB cluster name (
variables.tf), remember to replace
my-clusterin your configuration.
The default configuration in your
poc.yaml file will create a fully-functional cluster without any modifications.
In many cases, the configuration of TidbCluster can be changed even after it's deployed. For example, you can choose to add TiFlash, TiDB-Binlog, TiCDC, and other features after the cluster is already created.
In both cases, you need to enable TLS in the CRD and add Kubernetes Secrets to give the cluster resources acceess to TLS certificates.
If you want to enable TLS in your cluster, you should first follow the Create TLS Certificates Using CFSSL guide.
After creating Secrets with your TLS certificates, make these modifications to the
- If you want to enable TLS between MySQL-compatible clients and TiDB server, set
- If you want to enable TLS between the components of TiDB cluster, set
Create TiDB pods
A number of different pods will be created in groups. First, the PD pods, then the TiKV pods, and later the TiDB pods.
You can use
kubectl get pod to see the progress of the deployment.
NAME READY STATUS RESTARTS AGE my-cluster-discovery-d9854558f-gxpsb 1/1 Running 0 7m6s my-cluster-pd-0 1/1 Running 0 7m6s my-cluster-pd-1 1/1 Running 2 7m6s my-cluster-pd-2 1/1 Running 0 7m6s my-cluster-tidb-0 2/2 Running 0 3m19s my-cluster-tidb-1 2/2 Running 0 3m19s my-cluster-tikv-0 1/1 Running 0 3m38s my-cluster-tikv-1 1/1 Running 0 3m38s my-cluster-tikv-2 1/1 Running 0 3m38s
As soon as you see pods for all 3 pod types and all pods show "Running", you can move on to connecting to your cluster.