pingcap / tidb-operator

TiDB operator creates and manages TiDB clusters running in Kubernetes.
https://docs.pingcap.com/tidb-in-kubernetes/
Apache License 2.0
1.24k stars 499 forks source link

Persist the prometheus-rules directory in initialization configuration of TM #4510

Open wxiaoke opened 2 years ago

wxiaoke commented 2 years ago

At present, the persistent storage of tm is the data directory in the prometheus container. If the rules of prometheus are manually changed, persistent storage cannot be performed. It is recommended to persist this directory as well.

Whether to consider adding prometheus-rules to the data directory

KanShiori commented 2 years ago

WDYT @mikechengwei

DanielZhangQD commented 2 years ago

@wxiaoke Does https://docs.pingcap.com/tidb-in-kubernetes/dev/monitor-a-tidb-cluster#use-a-customized-configuration-file this work for you?

wxiaoke commented 2 years ago

NO,The following step is working. 使用 pvc 持久化步骤更新:

  1. 需要创建一个 pvc
 cat pvc1.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pro-rules
  namespace: tidb-cluster
spec:
  storageClassName: local-storage
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  1. 然后更改 tidb-monitor 配置
  additionalVolumes:
  - name: pro-rules
    persistentVolumeClaim:
      claimName: pro-rules
  prometheus:
    additionalVolumeMounts:
    - name: pro-rules
      mountPath: "/prometheus-rules/rules/"
  1. 创建 tm 并观察挂载情况 origin_img_v2_d799fdcc-d683-4326-9e60-0985f7b627ag