diff --git a/docs/api-references/docs.md b/docs/api-references/docs.md
index 9f06f5dc03b..ed6bd8f0469 100644
--- a/docs/api-references/docs.md
+++ b/docs/api-references/docs.md
@@ -25497,6 +25497,11 @@ github.com/pingcap/tidb-operator/pkg/apis/label.Label
+ MatchLabels is used to overwrite generated corev1.TopologySpreadConstraints.NodeSelector.
+corev1.TopologySpreadConstraint generated in component_spec.go will set a
+NodeSelector automatically with some KV.
+Historically, it is l[“comp”] = “” for component tiproxy. And we will use
+MatchLabels to keep l[“comp”] = “” for old clusters with tiproxy/
|
diff --git a/pkg/apis/pingcap/v1alpha1/types.go b/pkg/apis/pingcap/v1alpha1/types.go
index 217332f2c27..0f656575091 100644
--- a/pkg/apis/pingcap/v1alpha1/types.go
+++ b/pkg/apis/pingcap/v1alpha1/types.go
@@ -3002,7 +3002,13 @@ type TopologySpreadConstraint struct {
// WhenUnsatisfiable is default set to DoNotSchedule
// LabelSelector is generated by component type
// See pkg/apis/pingcap/v1alpha1/tidbcluster_component.go#TopologySpreadConstraints()
- TopologyKey string `json:"topologyKey"`
+ TopologyKey string `json:"topologyKey"`
+ // MatchLabels is used to overwrite generated corev1.TopologySpreadConstraints.NodeSelector.
+ //
+ // corev1.TopologySpreadConstraint generated in component_spec.go will set a
+ // NodeSelector automatically with some KV.
+ // Historically, it is l["comp"] = "" for component tiproxy. And we will use
+ // MatchLabels to keep l["comp"] = "" for old clusters with tiproxy/
MatchLabels label.Label `json:"matchLabels"`
}