From 48d02b161ed5e4e33537473e85ef964b8872758e Mon Sep 17 00:00:00 2001 From: Yifan Xu Date: Fri, 2 Dec 2022 15:41:33 +0800 Subject: [PATCH] init commit --- embed/examples/cluster/local.tpl | 8 ++++- embed/examples/cluster/minimal.yaml | 17 ++++++++++ embed/examples/cluster/multi-dc.yaml | 19 ++++++++++- embed/examples/cluster/topology.example.yaml | 2 +- .../scripts/run_tidb-dashboard.sh.tpl | 7 +++- pkg/cluster/spec/dashboard.go | 28 +++++++++------- pkg/cluster/template/scripts/dashboard.go | 33 +++++++++++++------ 7 files changed, 88 insertions(+), 26 deletions(-) diff --git a/embed/examples/cluster/local.tpl b/embed/examples/cluster/local.tpl index a5b0679551..6ec9811a21 100644 --- a/embed/examples/cluster/local.tpl +++ b/embed/examples/cluster/local.tpl @@ -62,4 +62,10 @@ alertmanager_servers: {{- range .AlertManagerServers }} - host: {{ . }} {{- end }} -{{ end }} \ No newline at end of file +{{ end }} +{{- if .TidbDashboardServers }} +tidb_dashboard_servers: + {{- range .TidbDashboardServers }} + - host: {{ . }} +{{- end }} +{{ end }} diff --git a/embed/examples/cluster/minimal.yaml b/embed/examples/cluster/minimal.yaml index 447f7943d9..54d6eee968 100644 --- a/embed/examples/cluster/minimal.yaml +++ b/embed/examples/cluster/minimal.yaml @@ -258,3 +258,20 @@ alertmanager_servers: # data_dir: "/tidb-data/alertmanager-9093" # # Alertmanager log file storage directory. # log_dir: "/tidb-deploy/alertmanager-9093/log" + +# # Server configs are used to specify the configuration of TiDB Dashboard Servers. +tidb_dashboard_servers: + # # The ip address of the PD Server. + - host: 10.0.1.11 + # # SSH port of the server. + # ssh_port: 22 + # # port of TiDB Dashboard + # port: 2380 + # # TiDB Dashboard deployment file, startup script, configuration file storage directory. + # deploy_dir: "/tidb-deploy/tidb-dashboard-23333" + # # PD Server data storage directory. + # data_dir: "/tidb-data/tidb-dashboard-23333" + # # PD Server log file storage directory. + # log_dir: "/tidb-deploy/tidb-dashboard-23333/log" + # # numa node bindings. + # numa_node: "0,1" diff --git a/embed/examples/cluster/multi-dc.yaml b/embed/examples/cluster/multi-dc.yaml index 37e8ded064..d92becdfe7 100644 --- a/embed/examples/cluster/multi-dc.yaml +++ b/embed/examples/cluster/multi-dc.yaml @@ -61,7 +61,7 @@ server_configs: # tiflash-learner: pd: # # Label level settings. - replication.location-labels: ["zone","dc","rack","host"] + replication.location-labels: [ "zone","dc","rack","host" ] # # Number of replicas of TiKV data replication.max-replicas: 5 # # Prohibit the leader be scheduled to the specified label place. @@ -310,3 +310,20 @@ alertmanager_servers: # data_dir: "/tidb-data/alertmanager-9093" # # Alertmanager log file storage directory. # log_dir: "/tidb-deploy/alertmanager-9093/log" + +# # Server configs are used to specify the configuration of TiDB Dashboard Servers. +tidb_dashboard_servers: + # # The ip address of the PD Server. + - host: 10.0.1.11 + # # SSH port of the server. + # ssh_port: 22 + # # port of TiDB Dashboard + # port: 2380 + # # TiDB Dashboard deployment file, startup script, configuration file storage directory. + # deploy_dir: "/tidb-deploy/tidb-dashboard-23333" + # # PD Server data storage directory. + # data_dir: "/tidb-data/tidb-dashboard-23333" + # # PD Server log file storage directory. + # log_dir: "/tidb-deploy/tidb-dashboard-23333/log" + # # numa node bindings. + # numa_node: "0,1" diff --git a/embed/examples/cluster/topology.example.yaml b/embed/examples/cluster/topology.example.yaml index 38c477f819..d74e29f36e 100644 --- a/embed/examples/cluster/topology.example.yaml +++ b/embed/examples/cluster/topology.example.yaml @@ -296,7 +296,7 @@ kvcdc_servers: # # Server configs are used to specify the configuration of TiDB Dashboard Servers. tidb_dashboard_servers: - # # The ip address of the PD Server. + # # The ip address of the TiDB Dashboard server. - host: 10.0.1.11 # # SSH port of the server. # ssh_port: 22 diff --git a/embed/templates/scripts/run_tidb-dashboard.sh.tpl b/embed/templates/scripts/run_tidb-dashboard.sh.tpl index 553b2d713b..aef47f8ed9 100644 --- a/embed/templates/scripts/run_tidb-dashboard.sh.tpl +++ b/embed/templates/scripts/run_tidb-dashboard.sh.tpl @@ -17,7 +17,12 @@ exec bin/tidb-dashboard \ --port="{{.Port}}" \ --pd="{{.PD}}" \ --data-dir="{{.DataDir}}" \ -{{- if .TLSEnabled}} +{{- if .ClusterTLSEnabled}} + --tidb-ca tls/ca.crt \ + --tidb-cert tls/tidb-dashboard.crt \ + --tidb-key tls/tidb-dashboard.pem \ +{{- end}} +{{- if .MysqlClientTLSEnabled}} --tidb-ca tls/ca.crt \ --tidb-cert tls/tidb-dashboard.crt \ --tidb-key tls/tidb-dashboard.pem \ diff --git a/pkg/cluster/spec/dashboard.go b/pkg/cluster/spec/dashboard.go index cab87f423e..9dd373e7ae 100644 --- a/pkg/cluster/spec/dashboard.go +++ b/pkg/cluster/spec/dashboard.go @@ -168,15 +168,16 @@ func (i *DashboardInstance) InitConfig( pds = append(pds, pdspec.GetAdvertiseClientURL(enableTLS)) } cfg := &scripts.DashboardScript{ - TidbVersion: clusterVersion, - IP: i.GetHost(), - DeployDir: paths.Deploy, - DataDir: paths.Data[0], - LogDir: paths.Log, - Port: spec.Port, - NumaNode: spec.NumaNode, - PD: strings.Join(pds, ","), - TLSEnabled: enableTLS, + TidbVersion: clusterVersion, + IP: i.GetHost(), + DeployDir: paths.Deploy, + DataDir: paths.Data[0], + LogDir: paths.Log, + Port: spec.Port, + NumaNode: spec.NumaNode, + PD: strings.Join(pds, ","), + ClusterTLSEnabled: enableTLS, + ClusterTLSCAPath: "placeholder", } fp := filepath.Join(paths.Cache, fmt.Sprintf("run_tidb-dashboard_%s_%d.sh", i.GetHost(), i.GetPort())) @@ -203,7 +204,10 @@ func (i *DashboardInstance) InitConfig( return checkConfig(ctx, e, i.ComponentName(), clusterVersion, i.OS(), i.Arch(), i.ComponentName()+".toml", paths, nil) } -// setTLSConfig set TLS Config to support enable/disable TLS -func (i *DashboardInstance) setTLSConfig(ctx context.Context, enableTLS bool, configs map[string]any, paths meta.DirPaths) (map[string]any, error) { - return nil, nil +func (i *DashboardInstance) setClusterTLS() { + +} + +func (i *DashboardInstance) setMysqlClientTLS() { + } diff --git a/pkg/cluster/template/scripts/dashboard.go b/pkg/cluster/template/scripts/dashboard.go index a39cfbe80c..6c53754a0d 100644 --- a/pkg/cluster/template/scripts/dashboard.go +++ b/pkg/cluster/template/scripts/dashboard.go @@ -22,17 +22,30 @@ import ( "github.com/pingcap/tiup/embed" ) -// DashboardScript represent the data to generate cdc config +// DashboardScript represents the data structure for generating startup shell scripts, +// with the help of Go Templates. type DashboardScript struct { - TidbVersion string - IP string - Port int - DeployDir string - LogDir string - DataDir string - NumaNode string - TLSEnabled bool - PD string + TidbVersion string + IP string + Port int + DeployDir string + LogDir string + DataDir string + NumaNode string + PD string + Telemetry bool + Experimental bool + PathPrefix string + + ClusterTLSEnabled bool + ClusterTLSCAPath string + ClusterTLSCertPath string + ClusterTLSKeyPath string + + MysqlClientTLSEnabled bool + MysqlClientTLSCAPath string + MysqlClientTLSCertPath string + MysqlClientTLSKeyPath string } // ConfigToFile write config content to specific file.