-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
en, zh: move tidb-operator architecture section to a new page (#388)
* Move tidb-operator architecture section to a new page * Apply suggestions from code review Co-authored-by: Ran <huangran@pingcap.com> * Apply suggestions from code review Co-authored-by: Ran <huangran@pingcap.com> Co-authored-by: Ran <huangran@pingcap.com>
- Loading branch information
Showing
6 changed files
with
98 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
title: TiDB Operator Architecture | ||
summary: Learn the architecture of TiDB Operator and how it works. | ||
category: reference | ||
--- | ||
|
||
# TiDB Operator Architecture | ||
|
||
This document describes the architecture of TiDB Operator and how it works. | ||
|
||
## Architecture | ||
|
||
The following diagram is an overview of the architecture of TiDB Operator. | ||
|
||
![TiDB Operator Overview](/media/tidb-operator-overview-1.1.png) | ||
|
||
`TidbCluster`, `TidbMonitor`, `TidbInitializer`, `Backup`, `Restore`, `BackupSchedule`, and `TidbClusterAutoScaler` are custom resources defined by CRD (`CustomResourceDefinition`). | ||
|
||
* `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. | ||
|
||
## Control flow | ||
|
||
The following diagram 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. | ||
|
||
![TiDB Operator Control Flow](/media/tidb-operator-control-flow-1.1.png) | ||
|
||
The overall control flow is described as follows: | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
title: TiDB Operator 架构 | ||
summary: 了解 TiDB Operator 架构及其工作原理。 | ||
category: reference | ||
--- | ||
|
||
# TiDB Operator 架构 | ||
|
||
本文档介绍 TiDB Operator 的架构及其工作原理。 | ||
|
||
## 架构 | ||
|
||
下图是 TiDB Operator 的架构概览。 | ||
|
||
![TiDB Operator Overview](/media/tidb-operator-overview-1.1.png) | ||
|
||
其中,`TidbCluster`、`TidbMonitor`、`TidbInitializer`、`Backup`、`Restore`、`BackupSchedule`、`TidbClusterAutoScaler` 是由 CRD(`CustomResourceDefinition`)定义的自定义资源: | ||
|
||
* `TidbCluster` 用于描述用户期望的 TiDB 集群 | ||
* `TidbMonitor` 用于描述用户期望的 TiDB 集群监控组件 | ||
* `TidbInitializer` 用于描述用户期望的 TiDB 集群初始化 Job | ||
* `Backup` 用于描述用户期望的 TiDB 集群备份 | ||
* `Restore` 用于描述用户期望的 TiDB 集群恢复 | ||
* `BackupSchedule` 用于描述用户期望的 TiDB 集群周期性备份 | ||
* `TidbClusterAutoScaler` 用于描述用户期望的 TiDB 集群自动伸缩 | ||
|
||
TiDB 集群的编排和调度逻辑则由下列组件负责: | ||
|
||
* `tidb-controller-manager` 是一组 Kubernetes 上的自定义控制器。这些控制器会不断对比 `TidbCluster` 对象中记录的期望状态与 TiDB 集群的实际状态,并调整 Kubernetes 中的资源以驱动 TiDB 集群满足期望状态,并根据其他 CR 完成相应的控制逻辑; | ||
* `tidb-scheduler` 是一个 Kubernetes 调度器扩展,它为 Kubernetes 调度器注入 TiDB 集群特有的调度逻辑。 | ||
* `tidb-admission-webhook` 是一个 Kubernetes 动态准入控制器,完成 Pod、StatefulSet 等相关资源的修改、验证与运维。 | ||
|
||
此外,TiDB Operator 还提供了命令行接口 `tkctl` 用于运维集群和诊断集群问题。 | ||
|
||
## 流程解析 | ||
|
||
下图是 TiDB Operator 的控制流程解析。从 TiDB Operator v1.1 开始,TiDB 集群、监控、初始化、备份等组件,都通过 CR 进行部署、管理。 | ||
|
||
![TiDB Operator Control Flow](/media/tidb-operator-control-flow-1.1.png) | ||
|
||
整体的控制流程如下: | ||
|
||
1. 用户通过 kubectl 创建 `TidbCluster` 和其他 CR 对象,比如 `TidbMonitor` 等; | ||
2. TiDB Operator 会 watch `TidbCluster` 以及其它相关对象,基于集群的实际状态不断调整 PD、TiKV、TiDB 或者 Monitor 等组件的 `StatefulSet`、`Deployment` 和 `Service` 等对象; | ||
3. Kubernetes 的原生控制器根据 `StatefulSet`、`Deployment`、`Job` 等对象创建更新或删除对应的 `Pod`; | ||
4. PD、TiKV、TiDB 的 `Pod` 声明中会指定使用 `tidb-scheduler` 调度器,`tidb-scheduler` 会在调度对应 `Pod` 时应用 TiDB 的特定调度逻辑。 | ||
|
||
基于上述的声明式控制流程,TiDB Operator 能够自动进行集群节点健康检查和故障恢复。部署、升级、扩缩容等操作也可以通过修改 `TidbCluster` 对象声明“一键”完成。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters