Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cluster: support tiproxy #2271

Merged
merged 7 commits into from
Oct 25, 2023
Merged
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
16 changes: 16 additions & 0 deletions embed/templates/config/prometheus.yml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,22 @@ scrape_configs:
- targets:
{{- range .TiDBStatusAddrs}}
- '{{.}}'
{{- end}}
- job_name: "tiproxy"
honor_labels: true # don't overwrite job & instance labels
metrics_path: /api/metrics
{{- if .TLSEnabled}}
scheme: https
tls_config:
insecure_skip_verify: false
ca_file: ../tls/ca.crt
cert_file: ../tls/prometheus.crt
key_file: ../tls/prometheus.pem
{{- end}}
static_configs:
- targets:
{{- range .TiProxyStatusAddrs}}
- '{{.}}'
{{- end}}
- job_name: "tikv"
honor_labels: true # don't overwrite job & instance labels
Expand Down
14 changes: 14 additions & 0 deletions embed/templates/scripts/run_tiproxy.sh.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -e

# WARNING: This file was auto-generated. Do not edit!
# All your edit might be overwritten!
DEPLOY_DIR={{.DeployDir}}
cd "${DEPLOY_DIR}" || exit 1

{{- if .NumaNode}}
exec numactl --cpunodebind={{.NumaNode}} --membind={{.NumaNode}} bin/tiproxy \
{{- else}}
exec bin/tiproxy \
{{- end}}
--config conf/tiproxy.toml
2 changes: 2 additions & 0 deletions pkg/cluster/ansible/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ server_configs:
pd: {}
tidb_dashboard: {}
tiflash: {}
tiproxy: {}
tiflash-learner: {}
pump: {}
drainer: {}
Expand All @@ -135,6 +136,7 @@ server_configs:
tidb_servers: []
tikv_servers: []
tiflash_servers: []
tiproxy_servers: []
pd_servers: []
monitoring_servers: []
`)
Expand Down
2 changes: 2 additions & 0 deletions pkg/cluster/ansible/test-data/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ topology:
pd: {}
tidb_dashboard: {}
tiflash: {}
tiproxy: {}
tiflash-learner: {}
pump: {}
drainer: {}
Expand Down Expand Up @@ -193,3 +194,4 @@ topology:
data_dir: data/alertmanager-9093
arch: amd64
os: linux
tiproxy_servers: []
2 changes: 2 additions & 0 deletions pkg/cluster/spec/bindversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ func TiDBComponentVersion(comp, version string) string {
ComponentTiSpark,
ComponentTiKVCDC: // TiKV-CDC use individual version.
return ""
case ComponentTiProxy:
return "nightly"
default:
return version
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/cluster/spec/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,13 @@ func (i *MonitorInstance) InitConfig(
cfig.AddTiDB(db.Host, uint64(db.StatusPort))
}
}
if servers, found := topoHasField("TiProxyServers"); found {
for i := 0; i < servers.Len(); i++ {
db := servers.Index(i).Interface().(*TiProxySpec)
uniqueHosts.Insert(db.Host)
cfig.AddTiProxy(db.Host, uint64(db.StatusPort))
}
}
if servers, found := topoHasField("TiFlashServers"); found {
for i := 0; i < servers.Len(); i++ {
flash := servers.Index(i).Interface().(*TiFlashSpec)
Expand Down
5 changes: 5 additions & 0 deletions pkg/cluster/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ type (
PD map[string]any `yaml:"pd"`
Dashboard map[string]any `yaml:"tidb_dashboard"`
TiFlash map[string]any `yaml:"tiflash"`
TiProxy map[string]any `yaml:"tiproxy"`
TiFlashLearner map[string]any `yaml:"tiflash-learner"`
Pump map[string]any `yaml:"pump"`
Drainer map[string]any `yaml:"drainer"`
Expand All @@ -125,6 +126,7 @@ type (
TiDBServers []*TiDBSpec `yaml:"tidb_servers"`
TiKVServers []*TiKVSpec `yaml:"tikv_servers"`
TiFlashServers []*TiFlashSpec `yaml:"tiflash_servers"`
TiProxyServers []*TiProxySpec `yaml:"tiproxy_servers"`
PDServers []*PDSpec `yaml:"pd_servers"`
DashboardServers []*DashboardSpec `yaml:"tidb_dashboard_servers,omitempty"`
PumpServers []*PumpSpec `yaml:"pump_servers,omitempty"`
Expand Down Expand Up @@ -502,6 +504,7 @@ func (s *Specification) Merge(that Topology) Topology {
PDServers: append(s.PDServers, spec.PDServers...),
DashboardServers: append(s.DashboardServers, spec.DashboardServers...),
TiFlashServers: append(s.TiFlashServers, spec.TiFlashServers...),
TiProxyServers: append(s.TiProxyServers, spec.TiProxyServers...),
PumpServers: append(s.PumpServers, spec.PumpServers...),
Drainers: append(s.Drainers, spec.Drainers...),
CDCServers: append(s.CDCServers, spec.CDCServers...),
Expand Down Expand Up @@ -712,6 +715,7 @@ func (s *Specification) ComponentsByStartOrder() (comps []Component) {
// "pd", "dashboard", "tikv", "pump", "tidb", "tiflash", "drainer", "cdc", "tikv-cdc", "prometheus", "grafana", "alertmanager"
comps = append(comps, &PDComponent{s})
comps = append(comps, &DashboardComponent{s})
comps = append(comps, &TiProxyComponent{s})
comps = append(comps, &TiKVComponent{s})
comps = append(comps, &PumpComponent{s})
comps = append(comps, &TiDBComponent{s})
Expand Down Expand Up @@ -739,6 +743,7 @@ func (s *Specification) ComponentsByUpdateOrder(curVer string) (comps []Componen
}
comps = append(comps, &PDComponent{s})
comps = append(comps, &DashboardComponent{s})
comps = append(comps, &TiProxyComponent{s})
comps = append(comps, &TiKVComponent{s})
comps = append(comps, &PumpComponent{s})
comps = append(comps, &TiDBComponent{s})
Expand Down
Loading
Loading