Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/basic/pd-micro-service-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ spec:
baseImage: hub.pingcap.net/devbuild/pd
version: v8.3.0-5427
replicas: 2
- name: "router"
baseImage: hub.pingcap.net/devbuild/pd
version: v8.3.0-5427
replicas: 2
tikv:
baseImage: pingcap/tikv
version: v8.5.3
Expand Down
1 change: 1 addition & 0 deletions manifests/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33240,6 +33240,7 @@ spec:
enum:
- tso
- scheduling
- router
type: string
nodeSelector:
additionalProperties:
Expand Down
1 change: 1 addition & 0 deletions manifests/crd/v1/pingcap.com_tidbclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8573,6 +8573,7 @@ spec:
enum:
- tso
- scheduling
- router
type: string
nodeSelector:
additionalProperties:
Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/label/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ const (
AnnTSODeleteSlots = "tso.tidb.pingcap.com/delete-slots"
// AnnSchedulingDeleteSlots is annotation key of pd ms scheduling delete slots.
AnnSchedulingDeleteSlots = "scheduling.tidb.pingcap.com/delete-slots"
// AnnRouterDeleteSlots is annotation key of pd ms router delete slots.
AnnRouterDeleteSlots = "router.tidb.pingcap.com/delete-slots"
// AnnTiDBDeleteSlots is annotation key of tidb delete slots.
AnnTiDBDeleteSlots = "tidb.tidb.pingcap.com/delete-slots"
// AnnTiKVDeleteSlots is annotation key of tikv delete slots.
Expand Down Expand Up @@ -169,6 +171,8 @@ const (
PDMSTSOLabelVal string = "tso"
// PDMSSchedulingLabelVal is pd microservice scheduling member type
PDMSSchedulingLabelVal string = "scheduling"
// PDMSRouterLabelVal is pd microservice router member type
PDMSRouterLabelVal string = "router"
// TiDBLabelVal is TiDB label value
TiDBLabelVal string = "tidb"
// TiKVLabelVal is TiKV label value
Expand Down Expand Up @@ -232,6 +236,8 @@ func PDMSLabel(name string) string {
return PDMSTSOLabelVal
case "scheduling":
return PDMSSchedulingLabelVal
case "router":
return PDMSRouterLabelVal
default:
panic(fmt.Sprintf("unknown pd ms name %s", name))
}
Expand Down Expand Up @@ -435,6 +441,8 @@ func (l Label) PDMS(name string) Label {
return l.Component(PDMSTSOLabelVal)
case "scheduling":
return l.Component(PDMSSchedulingLabelVal)
case "router":
return l.Component(PDMSRouterLabelVal)
default:
panic(fmt.Sprintf("unknown pd ms name %s", name))
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/pingcap/v1alpha1/component_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,8 @@ func getComponentLabelValue(c MemberType) string {
return label.PDMSTSOLabelVal
case PDMSSchedulingMemberType:
return label.PDMSSchedulingLabelVal
case PDMSRouterMerberType:
return label.PDMSRouterLabelVal
case TiDBMemberType:
return label.TiDBLabelVal
case TiKVMemberType:
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/pingcap/v1alpha1/component_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ func TestComponentStatus(t *testing.T) {
case PDMSSchedulingMemberType:
_, ok := status.(*PDMSStatus)
g.Expect(ok).To(BeTrue())
case PDMSRouterMerberType:
_, ok := status.(*PDMSStatus)
g.Expect(ok).To(BeTrue())
case TiDBMemberType:
_, ok := status.(*TiDBStatus)
g.Expect(ok).To(BeTrue())
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/pingcap/v1alpha1/tidbcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,8 @@ func (tc *TidbCluster) getDeleteSlots(component string) (deleteSlots sets.Int32)
key = label.AnnTSODeleteSlots
} else if component == label.PDMSSchedulingLabelVal {
key = label.AnnSchedulingDeleteSlots
} else if component == label.PDMSRouterLabelVal {
key = label.AnnRouterDeleteSlots
} else if component == label.TiDBLabelVal {
key = label.AnnTiDBDeleteSlots
} else if component == label.TiKVLabelVal {
Expand Down
8 changes: 6 additions & 2 deletions pkg/apis/pingcap/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ const (
PDMSTSOMemberType MemberType = "tso"
// PDMSSchedulingMemberType is pd microservice scheduling member type
PDMSSchedulingMemberType MemberType = "scheduling"
// PDMSRouterMerberType is pd microservice router member type
PDMSRouterMerberType MemberType = "router"
// TiDBMemberType is tidb member type
TiDBMemberType MemberType = "tidb"
// TiKVMemberType is tikv member type
Expand Down Expand Up @@ -113,13 +115,15 @@ func PDMSMemberType(name string) MemberType {
return PDMSTSOMemberType
case "scheduling":
return PDMSSchedulingMemberType
case "router":
return PDMSRouterMerberType
default:
panic(fmt.Sprintf("unknown pd ms name %s", name))
}
}

func IsPDMSMemberType(name MemberType) bool {
return name == PDMSTSOMemberType || name == PDMSSchedulingMemberType
return name == PDMSTSOMemberType || name == PDMSSchedulingMemberType || name == PDMSRouterMerberType
}

// MemberPhase is the current state of member
Expand Down Expand Up @@ -610,7 +614,7 @@ type PDMSSpec struct {
corev1.ResourceRequirements `json:",inline"`

// Name of the PD microservice
// +kubebuilder:validation:Enum:="tso";"scheduling"
// +kubebuilder:validation:Enum:="tso";"scheduling";"router"
Name string `json:"name"`

// Specify a Service Account for pd ms
Expand Down
2 changes: 1 addition & 1 deletion pkg/manager/member/pvc_resizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (p *pvcResizer) buildContextForTC(tc *v1alpha1.TidbCluster, status v1alpha1
}
storageVolumes = tc.Spec.PD.StorageVolumes
// PD microservice
case v1alpha1.PDMSTSOMemberType, v1alpha1.PDMSSchedulingMemberType:
case v1alpha1.PDMSTSOMemberType, v1alpha1.PDMSSchedulingMemberType, v1alpha1.PDMSRouterMerberType:
pdmsRequirement := util.MustNewRequirement(label.ComponentLabelKey, selection.Equals, []string{label.PDMSLabel(comp.String())})
ctx.selector = selector.Add(*pdmsRequirement)
for _, component := range tc.Spec.PDMS {
Expand Down
5 changes: 5 additions & 0 deletions pkg/manager/member/startscript/render_start_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var (
pdMS = map[string]RenderMap{
"tso": pdmsTSO,
"scheduling": pdmsScheduling,
"router": pdmsRouter,
}
pdmsTSO = RenderMap{
v1alpha1.StartScriptV1: v2.RenderPDTSOStartScript,
Expand All @@ -50,6 +51,10 @@ var (
v1alpha1.StartScriptV1: v2.RenderPDSchedulingStartScript,
v1alpha1.StartScriptV2: v2.RenderPDSchedulingStartScript,
}
pdmsRouter = RenderMap{
v1alpha1.StartScriptV1: v2.RenderPDRouterStartScript,
v1alpha1.StartScriptV2: v2.RenderPDRouterStartScript,
}
tidb = RenderMap{
v1alpha1.StartScriptV1: v1.RenderTiDBStartScript,
v1alpha1.StartScriptV2: v2.RenderTiDBStartScript,
Expand Down
4 changes: 4 additions & 0 deletions pkg/manager/member/startscript/v2/pd_start_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ func RenderPDSchedulingStartScript(tc *v1alpha1.TidbCluster) (string, error) {
return renderPDMSStartScript(tc, "scheduling")
}

func RenderPDRouterStartScript(tc *v1alpha1.TidbCluster) (string, error) {
return renderPDMSStartScript(tc, "router")
}

// RenderPDMCSStartScript renders TSO start script from TidbCluster
func renderPDMSStartScript(tc *v1alpha1.TidbCluster, name string) (string, error) {
m := &PDMSStartScriptModel{}
Expand Down
2 changes: 2 additions & 0 deletions pkg/manager/member/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ func getStsAnnotations(tcAnns map[string]string, component string) map[string]st
key = label.AnnTSODeleteSlots
case label.PDMSSchedulingLabelVal:
key = label.AnnSchedulingDeleteSlots
case label.PDMSRouterLabelVal:
key = label.AnnRouterDeleteSlots
case label.TiDBLabelVal:
key = label.AnnTiDBDeleteSlots
case label.TiKVLabelVal:
Expand Down
3 changes: 2 additions & 1 deletion pkg/manager/suspender/suspender.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var (
v1alpha1.PDMemberType,
v1alpha1.PDMSTSOMemberType,
v1alpha1.PDMSSchedulingMemberType,
v1alpha1.PDMSRouterMerberType,
}
suspendOrderForDM = []v1alpha1.MemberType{
v1alpha1.DMWorkerMemberType,
Expand Down Expand Up @@ -166,7 +167,7 @@ func (s *suspender) suspendSts(ctx *suspendComponentCtx) error {
case v1alpha1.PDMemberType:
ctx.status.(*v1alpha1.PDStatus).Members = nil
ctx.status.(*v1alpha1.PDStatus).Leader = v1alpha1.PDMember{}
case v1alpha1.PDMSTSOMemberType, v1alpha1.PDMSSchedulingMemberType:
case v1alpha1.PDMSTSOMemberType, v1alpha1.PDMSSchedulingMemberType, v1alpha1.PDMSRouterMerberType:
ctx.status.(*v1alpha1.PDMSStatus).Members = nil
case v1alpha1.TiDBMemberType:
ctx.status.(*v1alpha1.TiDBStatus).Members = nil
Expand Down
1 change: 1 addition & 0 deletions pkg/manager/volumes/selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func NewSelectorFactory() (*selectorFactory, error) {
v1alpha1.PDMemberType,
v1alpha1.PDMSTSOMemberType,
v1alpha1.PDMSSchedulingMemberType,
v1alpha1.PDMSRouterMerberType,
v1alpha1.TiProxyMemberType,
v1alpha1.TiDBMemberType,
v1alpha1.TiKVMemberType,
Expand Down
7 changes: 7 additions & 0 deletions pkg/manager/volumes/selector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ func TestNewSelector(t *testing.T) {

expected: "app.kubernetes.io/component=scheduling,app.kubernetes.io/instance=aaa,app.kubernetes.io/managed-by=tidb-operator,app.kubernetes.io/name=tidb-cluster",
},
{
desc: "selector for router",
instance: "aaa",
mt: v1alpha1.PDMSRouterMerberType,

expected: "app.kubernetes.io/component=router,app.kubernetes.io/instance=aaa,app.kubernetes.io/managed-by=tidb-operator,app.kubernetes.io/name=tidb-cluster",
},
{
desc: "selector for tidb",
instance: "aaa",
Expand Down
2 changes: 1 addition & 1 deletion pkg/manager/volumes/vol_compare_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (u *volCompareUtils) GetDesiredVolumes(tc *v1alpha1.TidbCluster, mt v1alpha
desiredVolumes = append(desiredVolumes, d)

storageVolumes = tc.Spec.PD.StorageVolumes
case v1alpha1.PDMSSchedulingMemberType, v1alpha1.PDMSTSOMemberType:
case v1alpha1.PDMSSchedulingMemberType, v1alpha1.PDMSTSOMemberType, v1alpha1.PDMSRouterMerberType:
for _, component := range tc.Spec.PDMS {
if strings.Contains(mt.String(), component.Name) {
defaultScName = component.StorageClassName
Expand Down
4 changes: 3 additions & 1 deletion pkg/monitor/monitor/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var (
pdPattern = "pd"
pdmsTSOPattern = "tso"
pdmsSchedulingPattern = "scheduling"
pdmsRouterPattern = "router"
tidbPattern = "tidb"
addressPattern = "(.+);(.+);(.+);(.+)"
tiflashPattern = "tiflash"
Expand Down Expand Up @@ -96,6 +97,7 @@ func newPrometheusConfig(cmodel *MonitorConfigModel) yaml.MapSlice {
scrapeJobs = append(scrapeJobs, scrapeJob("pd", pdPattern, cmodel, buildAddressRelabelConfigByComponent("pd"))...)
scrapeJobs = append(scrapeJobs, scrapeJob("tso", pdmsTSOPattern, cmodel, buildAddressRelabelConfigByComponent("tso"))...)
scrapeJobs = append(scrapeJobs, scrapeJob("scheduling", pdmsSchedulingPattern, cmodel, buildAddressRelabelConfigByComponent("scheduling"))...)
scrapeJobs = append(scrapeJobs, scrapeJob("router", pdmsRouterPattern, cmodel, buildAddressRelabelConfigByComponent("router"))...)
scrapeJobs = append(scrapeJobs, scrapeJob("tidb", tidbPattern, cmodel, buildAddressRelabelConfigByComponent("tidb"))...)
scrapeJobs = append(scrapeJobs, scrapeJob("tikv", tikvPattern, cmodel, buildAddressRelabelConfigByComponent("tikv"))...)
scrapeJobs = append(scrapeJobs, scrapeJob("tiproxy", tiproxyPattern, cmodel, buildAddressRelabelConfigByComponent("tiproxy"))...)
Expand Down Expand Up @@ -139,7 +141,7 @@ func buildAddressRelabelConfigByComponent(kind string) yaml.MapSlice {
}

switch strings.ToLower(kind) {
case "pd", "scheduling", "tso":
case "pd", "scheduling", "tso", "router":
return f()
case "tidb":
return f()
Expand Down
Loading
Loading