Skip to content

Commit

Permalink
en: update tidb operator overview (pingcap#56) (pingcap#106)
Browse files Browse the repository at this point in the history
* en: update tidb operator overview

* address comments

* fix broken links

* Update en/tidb-operator-overview.md

Co-Authored-By: Ran <huangran@pingcap.com>

* Update en/tidb-operator-overview.md

Co-Authored-By: Ran <huangran@pingcap.com>

Co-authored-by: Ran <huangran@pingcap.com>

Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>
Co-authored-by: Ran <huangran@pingcap.com>
  • Loading branch information
3 people authored Mar 30, 2020
1 parent 79793ee commit 74a5820
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
36 changes: 24 additions & 12 deletions en/tidb-operator-overview.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Overview of TiDB Operator
title: TiDB Operator Overview
summary: Learn the overview of TiDB Operator.
category: reference
---
Expand All @@ -22,22 +22,33 @@ The corresponding relationship between TiDB Operator and TiDB versions is as fol

## TiDB Operator architecture

![TiDB Operator Overview](/media/tidb-operator-overview.png)
![TiDB Operator Overview](/media/tidb-operator-overview-1.1.png)

`TidbCluster` is a custom resource defined by CRD (`CustomResourceDefinition`) and is used to describe the desired state of the TiDB cluster. The following components are responsible for the orchestration and scheduling logic in a TiDB cluster:
`TidbCluster`, `TidbMonitor`, `TidbInitializer`, `Backup`, `Restore`, `BackupSchedule`, and `TidbClusterAutoScaler` are custom resources defined by CRD (`CustomResourceDefinition`).

* `tidb-controller-manager` is a set of custom controllers in Kubernetes. These controllers constantly compare the desired state recorded in the `TidbCluster` object with the actual state of the TiDB cluster. They adjust the resources in Kubernetes to drive the TiDB cluster to meet the desired state;
* `tidb-scheduler` is a Kubernetes scheduler extension that injects the TiDB specific scheduling policies to the Kubernetes scheduler.
* `TidbCluster` describes the desired state of the TiDB cluster.
* `TidbMonitor` describes the monitoring components of the TiDB cluster.
* `TidbInitializer` describes the desired initialization Job of the TiDB cluster.
* `Backup` describes the desired backup of the TiDB cluster.
* `Restore` describes the desired restoration of the TiDB cluster.
* `BackupSchedule` describes the scheduled backup of the TiDB cluster.
* `TidbClusterAutoScaler` describes the automatic scaling of the TiDB cluster.

The following components are responsible for the orchestration and scheduling logic in a TiDB cluster:

* `tidb-controller-manager` is a set of custom controllers in Kubernetes. These controllers constantly compare the desired state recorded in the `TidbCluster` object with the actual state of the TiDB cluster. They adjust the resources in Kubernetes to drive the TiDB cluster to meet the desired state and complete the corresponding control logic according to other CRs;
* `tidb-scheduler` is a Kubernetes scheduler extension that injects the TiDB specific scheduling policies to the Kubernetes scheduler;
* `tidb-admission-webhook` is a dynamic admission controller in Kubernetes, which completes the modification, verification, operation and maintenance of Pod, StatefulSet and other related resources.

In addition, TiDB Operator also provides `tkctl`, the command-line interface for TiDB clusters in Kubernetes. It is used for cluster operations and troubleshooting cluster issues.

![TiDB Operator Control Flow](/media/tidb-operator-control-flow.png)
![TiDB Operator Control Flow](/media/tidb-operator-control-flow-1.1.png)

The diagram above is the analysis of the control flow of TiDB Operator. Because TiDB clusters also need components such as monitoring, initialization, scheduled backup, Binlog and so on, TiDB Operator encapsulates the definition of these components in the Helm chart. The overall control process is as follows:
The diagram above is the analysis of the control flow of TiDB Operator. Starting from TiDB Operator v1.1, the TiDB cluster, monitoring, initialization, backup, and other components are deployed and managed using CR. The overall control flow is described as follows:

1. The user creates a `TidbCluster` object and a corresponding series of Kubernetes-native objects through Helm, such as a `CronJob` that performs scheduled backups;
2. TiDB Operator watches `TidbCluster` and other related objects, and constantly adjust the `StatefulSet` and `Service` objects of PD, TiKV, and TiDB based on the actual state of the cluster;
3. Kubernetes' native controller creates, updates, and deletes the corresponding `Pod` based on objects such as `StatefulSet`, `Deployment`, and `CronJob`;
1. The user creates a `TidbCluster` object and other CR objects through kubectl, such as `TidbMonitor`;
2. TiDB Operator watches `TidbCluster` and other related objects, and constantly adjust the `StatefulSet`, `Deployment`, `Service`, and other objects of PD, TiKV, TiDB, Monitor or other components based on the actual state of the cluster;
3. Kubernetes' native controllers create, update, or delete the corresponding `Pod` based on objects such as `StatefulSet`, `Deployment`, and `Job`;
4. In the `Pod` declaration of PD, TiKV, and TiDB, the `tidb-scheduler` scheduler is specified. `tidb-scheduler` applies the specific scheduling logic of TiDB when scheduling the corresponding `Pod`.

Based on the above declarative control flow, TiDB Operator automatically performs health check and fault recovery for the cluster nodes. You can easily modify the `TidbCluster` object declaration to perform operations such as deployment, upgrade and scaling.
Expand Down Expand Up @@ -65,15 +76,16 @@ TiDB Operator provides several ways to deploy TiDB clusters in Kubernetes:

You also need to adjust the configuration of the Kubernetes cluster based on [Prerequisites for TiDB in Kubernetes](prerequisites.md) and configure the local PV for your Kubernetes cluster to achieve low latency of local storage for TiKV according to [Local PV Configuration](configure-storage-class.md#local-pv-configuration).

Before deploying TiDB on any of the above two environments, you can always refer to [TiDB Cluster Configuration Document](configure-a-tidb-cluster.md) to customize TiDB configurations.
Before deploying TiDB on any of the above two environments, you can always refer to [TiDB Cluster Configuration Document](configure-cluster-using-tidbcluster.md) to customize TiDB configurations.

After the deployment is complete, see the following documents to use, operate, and maintain TiDB clusters in Kubernetes:

+ [Access the TiDB Cluster](access-tidb.md)
+ [Scale TiDB Cluster](scale-a-tidb-cluster.md)
+ [Upgrade TiDB Cluster](upgrade-a-tidb-cluster.md#upgrade-the-version-of-tidb-cluster)
+ [Change the Configuration of TiDB Cluster](upgrade-a-tidb-cluster.md#change-the-configuration-of-tidb-cluster)
+ [Backup and Restoration Based on Helm Charts](backup-and-restore-using-helm-charts.md)
+ [Back up a TiDB Cluster](backup-to-aws-s3-using-br.md)
+ [Restore a TiDB Cluster](restore-from-aws-s3-using-br.md)
+ [Automatic Failover](use-auto-failover.md)
+ [Monitor a TiDB Cluster in Kubernetes](monitor-a-tidb-cluster.md)
+ [Collect TiDB Logs in Kubernetes](collect-tidb-logs.md)
Expand Down
2 changes: 1 addition & 1 deletion en/upgrade-a-tidb-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ It is recommended that you set `spec.configUpdateStrategy` to `RollingUpdate` to

1. Set `spec.configUpdateStrategy` to `RollingUpdate`.

2. Modify the configuration items of the cluster, as described in [Configure a TiDB Cluster](configure-a-tidb-cluster.md)
2. Modify the configuration items of the cluster, as described in [Configure a TiDB Cluster](configure-cluster-using-tidbcluster.md)

3. View the update progress:

Expand Down

0 comments on commit 74a5820

Please sign in to comment.