Skip to content

Commit

Permalink
support-multi-version-dashboard (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
qiffang authored and tennix committed May 10, 2019
1 parent d0556fc commit 0c04d39
Show file tree
Hide file tree
Showing 18 changed files with 81,513 additions and 52 deletions.
1,887 changes: 1,887 additions & 0 deletions charts/tidb-cluster/templates/config/v2/binlog.tpl

Large diffs are not rendered by default.

3,859 changes: 3,859 additions & 0 deletions charts/tidb-cluster/templates/config/v2/overview.tpl

Large diffs are not rendered by default.

5,997 changes: 5,997 additions & 0 deletions charts/tidb-cluster/templates/config/v2/pd.tpl

Large diffs are not rendered by default.

6,994 changes: 6,994 additions & 0 deletions charts/tidb-cluster/templates/config/v2/tidb.tpl

Large diffs are not rendered by default.

15,508 changes: 15,508 additions & 0 deletions charts/tidb-cluster/templates/config/v2/tikv_pull.tpl

Large diffs are not rendered by default.

1,877 changes: 1,877 additions & 0 deletions charts/tidb-cluster/templates/config/v3/binlog.tpl

Large diffs are not rendered by default.

3,778 changes: 3,778 additions & 0 deletions charts/tidb-cluster/templates/config/v3/overview.tpl

Large diffs are not rendered by default.

6,163 changes: 6,163 additions & 0 deletions charts/tidb-cluster/templates/config/v3/pd.tpl

Large diffs are not rendered by default.

7,384 changes: 7,384 additions & 0 deletions charts/tidb-cluster/templates/config/v3/tidb.tpl

Large diffs are not rendered by default.

17,033 changes: 17,033 additions & 0 deletions charts/tidb-cluster/templates/config/v3/tikv_detail.tpl

Large diffs are not rendered by default.

4,600 changes: 4,600 additions & 0 deletions charts/tidb-cluster/templates/config/v3/tikv_summary.tpl

Large diffs are not rendered by default.

6,280 changes: 6,280 additions & 0 deletions charts/tidb-cluster/templates/config/v3/tikv_ts.tpl

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion charts/tidb-cluster/templates/monitor-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ data:
{{ tuple "config/_grafana-datasource.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
dashboard-config: |-
{{ tuple "config/_grafana-dashboard.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
grafana-prestart: |-
grafana-prestart: |
{{- tuple "scripts/_grafana-prestart.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
{{- end }}
{{- end }}
36 changes: 0 additions & 36 deletions charts/tidb-cluster/templates/monitor-dashboard-configmap.yaml

This file was deleted.

25 changes: 25 additions & 0 deletions charts/tidb-cluster/templates/monitor-dashboard-configmap_v2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# the dashboard is here : https://github.com/pingcap/tidb-ansible/tree/release-2.1/scripts
{{- if .Values.monitor.grafana.create }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "cluster.name" . }}-monitor-dashboard-v2
labels:
app.kubernetes.io/name: {{ template "chart.name" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: monitor
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
data:
pdV2.json: |
{{ include "pd_dashboard_v2" . | indent 4 }}
overviewV2.json: |
{{ include "overview_dashboard_v2" . | indent 4 }}
tidbV2.json: |
{{ include "tidb_dashboard_v2" . | indent 4 }}
tikvV2.json: |
{{ include "tikv_dashboard_v2" . | indent 4 }}
binlogV2.json: |
{{ include "binlog_v2" . | indent 4 }}
{{- end }}

44 changes: 44 additions & 0 deletions charts/tidb-cluster/templates/monitor-dashboard-configmap_v3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# the dashboard is here : https://github.com/pingcap/tidb-ansible/tree/release-3.0/scripts
{{- if .Values.monitor.grafana.create }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "cluster.name" . }}-monitor-dashboard-v3
labels:
app.kubernetes.io/name: {{ template "chart.name" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: monitor
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
data:
pdV3.json: |
{{ include "pd_dashboard_v3" . | indent 4 }}
overviewV3.json: |
{{ include "overview_dashboard_v3" . | indent 4 }}
tidbV3.json: |
{{ include "tidb_dashboard_v3" . | indent 4 }}
tikvV3.json: |
{{ include "tikv_dashboard_v3" . | indent 4 }}
binlogV3.json: |
{{ include "binlog_v3" . | indent 4 }}
{{- end }}
---
{{- if .Values.monitor.grafana.create }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "cluster.name" . }}-monitor-dashboard-extra-v3
labels:
app.kubernetes.io/name: {{ template "chart.name" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: monitor
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
data:
tikvSummaryV3.json: |
{{ include "tikv_summary_dashboard_v3" . | indent 4 }}
tikvTSV3.json: |
{{ include "tikv_ts_dashboard_v3" . | indent 4 }}
{{- end }}


22 changes: 17 additions & 5 deletions charts/tidb-cluster/templates/monitor-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ spec:
lifecycle:
postStart:
exec:
command: ["/bin/sh", "/tmp/grafanaPrestart.sh"]
command: ["/bin/bash", "/tmp/grafanaPrestart.sh"]
{{- if .Values.monitor.grafana.resources }}
resources:
{{ toYaml .Values.monitor.grafana.resources | indent 12 }}
Expand Down Expand Up @@ -136,8 +136,14 @@ spec:
- mountPath: /etc/grafana/provisioning/dashboards
name: dashboards-provisioning
readOnly: false
- mountPath: /tmp/dashboard-gz
name: dashboard-gz
- mountPath: /tmp/dashboard-v2
name: dashboard-v2
readOnly: false
- mountPath: /tmp/dashboard-v3
name: dashboard-v3
readOnly: false
- mountPath: /tmp/dashboard-v3/extra
name: dashboard-extra-v3
readOnly: false
- mountPath: /grafana-dashboard-definitions/tidb
name: grafana-dashboard
Expand Down Expand Up @@ -178,8 +184,14 @@ spec:
- emptyDir: {}
name: grafana-dashboard
- configMap:
name: {{ template "cluster.name" . }}-monitor-dashboard
name: dashboard-gz
name: {{ template "cluster.name" . }}-monitor-dashboard-v2
name: dashboard-v2
- configMap:
name: {{ template "cluster.name" . }}-monitor-dashboard-v3
name: dashboard-v3
- configMap:
name: {{ template "cluster.name" . }}-monitor-dashboard-extra-v3
name: dashboard-extra-v3
- configMap:
name: {{ template "cluster.name" . }}-monitor
items:
Expand Down
76 changes: 66 additions & 10 deletions charts/tidb-cluster/templates/scripts/_grafana-prestart.sh.tpl
Original file line number Diff line number Diff line change
@@ -1,16 +1,72 @@
#!/bin/sh
#!/bin/bash

#decompress dashboard files
gzip -dc /tmp/dashboard-gz/tidb.json.gz > /grafana-dashboard-definitions/tidb/tidb.json
gzip -dc /tmp/dashboard-gz/pd.json.gz > /grafana-dashboard-definitions/tidb/pd.json
gzip -dc /tmp/dashboard-gz/tikv.json.gz > /grafana-dashboard-definitions/tidb/tikv.json
gzip -dc /tmp/dashboard-gz/overview.json.gz > /grafana-dashboard-definitions/tidb/overview.json
#check tidb cluster version
TiDBVersion={{ .Values.tidb.image }}
TiKVVersion={{ .Values.tikv.image }}
PDVersion={{ .Values.pd.image }}
PumpVersion={{ .Values.binlog.pump.image }}
V3=v3

#check binlog switch
enablePump={{ .Values.binlog.pump.create | default false }}

#replace dashboard name using cluster name
clusterName={{ template "cluster.name" . }}
clusterName=${clusterName:-"TiDB-Cluster"}

sed -i 's/TIDB-Cluster-TiDB/'$clusterName'-TiDB/g' /grafana-dashboard-definitions/tidb/tidb.json
sed -i 's/TIDB-Cluster-PD/'$clusterName'-PD/g' /grafana-dashboard-definitions/tidb/pd.json
sed -i 's/TIDB-Cluster-TiKV/'$clusterName'-TiKV/g' /grafana-dashboard-definitions/tidb/tikv.json
sed -i 's/TIDB-Cluster-Overview/'$clusterName'-Overview/g' /grafana-dashboard-definitions/tidb/overview.json
#TiDB dashboard
if [[ $TiDBVersion =~ $V3 ]]
then
cp /tmp/dashboard-v3/tidbV3.json /grafana-dashboard-definitions/tidb/
else
cp /tmp/dashboard-v2/tidbV2.json /grafana-dashboard-definitions/tidb/
fi
sed -i 's/TIDB-Cluster-TiDB/'$clusterName'-TiDB/g' /grafana-dashboard-definitions/tidb/tidbV*.json

#Overview dashboard
if [[ $TiDBVersion =~ $V3 ]]
then
cp /tmp/dashboard-v3/overviewV3.json /grafana-dashboard-definitions/tidb/
else
cp /tmp/dashboard-v2/overviewV2.json /grafana-dashboard-definitions/tidb/
fi
sed -i 's/TIDB-Cluster-Overview/'$clusterName'-Overview/g' /grafana-dashboard-definitions/tidb/overviewV*.json

#PD dashboard
if [[ $PDVersion =~ $V3 ]]
then
cp /tmp/dashboard-v3/pdV3.json /grafana-dashboard-definitions/tidb/
else
cp /tmp/dashboard-v2/pdV2.json /grafana-dashboard-definitions/tidb/
fi
sed -i 's/TIDB-Cluster-PD/'$clusterName'-PD/g' /grafana-dashboard-definitions/tidb/pdV*.json

#TIKV dashboard
if [[ $TiKVVersion =~ $V3 ]]
then
cp /tmp/dashboard-v3/tikvV3.json /grafana-dashboard-definitions/tidb/
cp /tmp/dashboard-v3/extra/tikvSummaryV3.json /grafana-dashboard-definitions/tidb/
cp /tmp/dashboard-v3/extra/tikvTSV3.json /grafana-dashboard-definitions/tidb/
sed -i 's/TIDB-Cluster-TiKV-Summary/'$clusterName'-TiKV-Summary/g' /grafana-dashboard-definitions/tidb/tikvSummaryV3.json
sed -i 's/TIDB-Cluster-TiKV-Trouble-Shooting/'$clusterName'-TiKV-Trouble-Shooting/g' /grafana-dashboard-definitions/tidb/tikvTSV3.json
else
cp /tmp/dashboard-v2/tikvV2.json /grafana-dashboard-definitions/tidb/
fi
sed -i 's/TIDB-Cluster-TiKV/'$clusterName'-TiKV/g' /grafana-dashboard-definitions/tidb/tikvV*.json


#Binlog dashboard
if [[ $PumpVersion =~ $V3 ]]
then
if $enablePump
then
cp /tmp/dashboard-v3/binlogV3.json /grafana-dashboard-definitions/tidb/
sed -i 's/TIDB-Cluster-Binlog/'$clusterName'-Binlog/g' /grafana-dashboard-definitions/tidb/binlogV3.json
fi
else
if $enablePump
then
cp /tmp/dashboard-v2/binlogV2.json /grafana-dashboard-definitions/tidb/
sed -i 's/TIDB-Cluster-Binlog/'$clusterName'-Binlog/g' /grafana-dashboard-definitions/tidb/binlogV2.json
fi
fi

0 comments on commit 0c04d39

Please sign in to comment.