tidb-operator/examples/basic
Cody (Xuecheng) Zhang 8b4b5574cf
fix: fix some images for tidb-dashboard and BR (#6485)
2025-10-09 13:51:03 +08:00
..
README.md
pd-micro-service-cluster.yaml
tidb-cluster.yaml
tidb-dashboard.yaml fix: fix some images for tidb-dashboard and BR (#6485) 2025-10-09 13:51:03 +08:00
tidb-monitor.yaml

README.md

A Basic TiDB cluster with monitoring

Note:

This setup is for test or demo purpose only and IS NOT applicable for critical environment. Refer to the Documents for production setup.

The following steps will create a TiDB cluster with monitoring, the monitoring data is not persisted by default.

Prerequisites:

  • Has TiDB operator v1.1.0-beta.1 or higher version installed. Doc

  • Has default StorageClass configured, and there are enough PVs (by default, 6 PVs are required) of that storageClass:

    This could be verified by the following command:

    > kubectl get storageclass
    

    The output is similar to this:

    NAME                 PROVISIONER               AGE
    standard (default)   kubernetes.io/gce-pd      1d
    gold                 kubernetes.io/gce-pd      1d
    

    Alternatively, you could specify the storageClass explicitly by modifying tidb-cluster.yaml.

Install

The following commands is assumed to be executed in this directory.

Install the cluster:

> kubectl -n <namespace> apply -f ./

Wait for cluster Pods ready:

watch kubectl -n <namespace> get pod

Explore

Explore the TiDB sql interface:

> kubectl -n <namespace> port-forward svc/basic-tidb 4000:4000 &>/tmp/pf-tidb.log &
> mysql -h 127.0.0.1 -P 4000 -u root --comments

Explore the monitoring dashboards:

> kubectl -n <namespace> port-forward svc/basic-grafana 3000:3000 &>/tmp/pf-grafana.log &

Browse localhost:3000.

Destroy

> kubectl -n <namespace> delete -f ./

The PVCs used by TiDB cluster will not be deleted in the above process, therefore, the PVs will be not be released neither. You can delete PVCs and release the PVs by the following command:

> kubectl -n <namespace> delete pvc -l app.kubernetes.io/instance=basic,app.kubernetes.io/managed-by=tidb-operator