### Cluster Controller
Manages the primary `Cluster` custom resources, overseeing the entire lifecycle of a standard TiDB cluster. Its responsibilities include:
- Handling cluster creation, deletion, scaling, and upgrades.
- Assigning a `Keyspace` to a new cluster.
- Integrating with the observability (`o11y`) stack.
- Managing audit log configurations and other serverless features.

### Export Controller
Manages `Export` custom resources to handle data extraction from a TiDB cluster. Its responsibilities include:
- Creating and managing `dumpling` jobs to perform the data export.
- Supporting various export targets, including Amazon S3, Google Cloud Storage (GCS), and Azure Blob Storage.
- Cleaning up resources after the export is completed or has failed.

### Imports Controller
Manages `Import` custom resources to load data into a TiDB cluster. Its responsibilities include:
- Creating and managing `tidb-lightning` jobs to perform the data import.
- Configuring the lightning job with appropriate resources and connection details.
- Monitoring the import progress and updating the status of the `Import` resource.
- Cleaning up resources upon completion or failure.

### Keyspace Controller
Manages `Keyspace` custom resources, which represent a logical data partition within the TiDB cluster. Its responsibilities include:
- Interacting with the Placement Driver (PD) to create and remove keyspaces.
- Running an "activation" job for newly created keyspaces to prepare them for use.
- Managing the lifecycle and finalizers of `Keyspace` objects.

### Keyspace Pool Config Controller
Manages a pool of ready-to-use keyspaces to speed up cluster provisioning. Its responsibilities include:
- Watching a `keyspace-pool-config` ConfigMap for the desired pool size.
- Creating or deleting `Keyspace` resources to match the configured size.
- Ensuring a buffer of available keyspaces is always maintained.

### Node Rebalance Controller
Monitors nodes for spot instance interruptions or rebalancing signals. Its responsibilities include:
- Detecting taints that signal a node needs to be rebalanced.
- Preventing the cluster autoscaler from adding new nodes to the affected zone during rebalancing.
- Evicting pods from the signaled node to allow them to be rescheduled elsewhere.

### Node Recover Controller
Recovers nodes that were previously cordoned off due to forced evictions. Its responsibilities include:
- Monitoring nodes that have been marked as force-evicted.
- Checking the node's CPU and memory idle metrics over a period.
- Uncordoning the node and removing eviction-related annotations if it is deemed healthy and stable.

### Secret Syncer Controller
Ensures that critical secrets are available across multiple namespaces. Its responsibilities include:
- Watching a source secret (e.g., `tidb-session-certificate-secret`) in a central namespace.
- Copying and synchronizing this secret to all configured TiDB pool namespaces.

### TiDB Pod Controller
This package contains two controllers for managing TiDB pods:
- **Clean Controller**: Automatically cleans up `tidb-server` pods that have entered a `Terminated` state, ensuring that failed pods do not linger.
- **Sync Cache Controller**: Monitors the status of all `tidb-server` pods (Ready, Pending, Terminating) and updates an in-memory cache. This cache is used by other components for a real-time view of pod health.

### TiDB Pod Evicter Controller
Proactively manages resource utilization by evicting pods from overloaded nodes. Its responsibilities include:
- Monitoring node CPU and memory usage via Prometheus metrics.
- Identifying nodes that have breached a predefined resource threshold.
- Calculating a score for each pod on the overloaded node based on its resource usage and recent changes.
- Evicting the highest-scoring pods to reduce load on the node.

### TiDB Server Template Controller
Manages updates to the pod template for `tidb-server`. Its responsibilities include:
- Watching the `tidb-server-template` ConfigMap for changes.
- Locking the TiDB manager's free cache when the template is being updated to prevent new pods from being created with an old configuration.
- Unlocking the cache once the update is complete.

### Zone Redundant Evicter Controller
Ensures high availability by maintaining workload distribution across different availability zones. Its responsibilities include:
- Identifying a "main" availability zone from a ConfigMap.
- Evicting pods from nodes in other "standby" zones to consolidate workloads in the main zone.
- Handling different components (tidb, gateway, etc.) and unreachable nodes gracefully.
