title | summary | category |
---|---|---|
Deploy TiDB Operator in Kubernetes |
Learn how to deploy TiDB Operator in Kubernetes. |
how-to |
This document describes how to deploy TiDB Operator in Kubernetes.
Before deploying TiDB Operator, make sure the following items are installed on your machine:
- Kubernetes >= v1.12
- DNS addons
- PersistentVolume
- RBAC enabled (optional)
- Helm version >= 2.11.0 && < 3.0.0 && != 2.16.4
TiDB Operator runs in Kubernetes cluster. You can refer to the document of how to set up Kubernetes to set up a Kubernetes cluster. Make sure that the Kubernetes version is v1.12 or higher. If you are using AWS, GKE or local machines, here are quick-start tutorials:
TiDB Operator uses Persistent Volume to persist the data of TiDB cluster (including the database, monitoring data, and backup data), so the Kubernetes cluster must provide at least one kind of persistent volume. For better performance, it is recommended to use local SSD disk as the volumes. Follow this step to provision local persistent volumes.
It is recommended to enable RBAC in the Kubernetes cluster.
Refer to Use Helm to install Helm and configre it with the official PingCAP chart Repo.
Refer to Local PV Configuration to set up local persistent volumes in your Kubernetes cluster.
TiDB Operator uses CRD (Custom Resource Definition) to extend Kubernetes. Therefore, to use TiDB Operator, you must first create the TidbCluster
custom resource type, which is a one-time job in your Kubernetes cluster.
{{< copyable "shell-regular" >}}
kubectl apply -f https://raw.githubusercontent.com/pingcap/tidb-operator/master/manifests/crd.yaml && \
kubectl get crd tidbclusters.pingcap.com
After TidbCluster
custom resource type is created, install TiDB Operator in your Kubernetes cluster.
-
Get the
values.yaml
file of thetidb-operator
chart you want to install.{{< copyable "shell-regular" >}}
mkdir -p /home/tidb/tidb-operator && \ helm inspect values pingcap/tidb-operator --version=${chart_version} > /home/tidb/tidb-operator/values-tidb-operator.yaml
Note:
${chart_version}
represents the chart version of TiDB Operator. For example,v1.0.0
. You can view the currently supported versions by running thehelm search -l tidb-operator
command. -
Install TiDB Operator.
{{< copyable "shell-regular" >}}
helm install pingcap/tidb-operator --name=tidb-operator --namespace=tidb-admin --version=${chart_version} -f /home/tidb/tidb-operator/values-tidb-operator.yaml && \ kubectl get po -n tidb-admin -l app.kubernetes.io/name=tidb-operator
To customize TiDB Operator, modify /home/tidb/tidb-operator/values-tidb-operator.yaml
. The rest sections of the document use values.yaml
to refer to /home/tidb/tidb-operator/values-tidb-operator.yaml
TiDB Operator contains two components:
- tidb-controller-manager
- tidb-scheduler
These two components are stateless and deployed via Deployment
. You can customize resource limit
, request
, and replicas
in the values.yaml
file.
After modifying values.yaml
, run the following command to apply this modification:
{{< copyable "shell-regular" >}}
helm upgrade tidb-operator pingcap/tidb-operator --version=${chart_version} -f /home/tidb/tidb-operator/values-tidb-operator.yaml