# https://docs.pingcap.com/tidb-in-kubernetes/stable/deploy-tidb-cluster
# https://github.com/pingcap/tidb-operator/blob/master/examples/basic/tidb-cluster.yaml
apiVersion: pingcap.com/v1alpha1
kind: TidbCluster
metadata:
  name: basic
  namespace: tidb-cluster
spec:
  version: v7.1.0
  timezone: UTC
  pvReclaimPolicy: Retain
  discovery: {}
  pd:
    baseImage: pingcap/pd
    maxFailoverCount: 0
    replicas: 3
    requests:
      cpu: {{ .Values.pd.requests.cpu | quote }}
      memory: {{ .Values.pd.requests.memory | quote }}
      storage: "10Gi"
    limits:
      cpu: {{ .Values.pd.limits.cpu | quote }}
      memory: {{ .Values.pd.limits.memory | quote }}
    config: {}
    annotations:
      ad.datadoghq.com/pd.check_names: '["prometheus"]'
      ad.datadoghq.com/pd.init_configs: '[{}]'
      ad.datadoghq.com/pd.instances: '[{"prometheus_url": "http://%%host%%:2379/metrics", "namespace": "tidb_pd", "metrics": ["pd_cluster_status", "pd_regions_status", "pd_schedule_operators_count", "pd_server_handle_requests_duration_seconds*"]}]'
    topologySpreadConstraints:
    - topologyKey: kubernetes.io/hostname
      maxSkew: 1
      whenUnsatisfiable: DoNotSchedule
  tikv:
    baseImage: pingcap/tikv
    maxFailoverCount: 0
    replicas: 3
    requests:
      cpu: {{ .Values.tikv.requests.cpu | quote }}
      memory: {{ .Values.tikv.requests.memory | quote }}
      storage: {{ .Values.tikv.requests.storage | quote }}
    limits:
      cpu: {{ .Values.tikv.limits.cpu | quote }}
      memory: {{ .Values.tikv.limits.memory | quote }}
    config: {}
    annotations:
      ad.datadoghq.com/tikv.check_names: '["prometheus"]'
      ad.datadoghq.com/tikv.init_configs: '[{}]'
      ad.datadoghq.com/tikv.instances: '[{"prometheus_url": "http://%%host%%:20180/metrics", "namespace": "tidb_tikv", "metrics": ["tikv_engine_size_bytes", "tikv_store_size_bytes", "tikv_grpc_msg_duration_seconds*", "tikv_scheduler_command_duration_seconds*", "tikv_storage_engine_async_request_duration_seconds*"]}]'
    topologySpreadConstraints:
    - topologyKey: kubernetes.io/hostname
      maxSkew: 1
      whenUnsatisfiable: DoNotSchedule
  tidb:
    baseImage: pingcap/tidb
    maxFailoverCount: 0
    replicas: 2
    requests:
      cpu: {{ .Values.tidb.requests.cpu | quote }}
      memory: {{ .Values.tidb.requests.memory | quote }}
    limits:
      cpu: {{ .Values.tidb.limits.cpu | quote }}
      memory: {{ .Values.tidb.limits.memory | quote }}
    service:
      type: ClusterIP
    config: {}
    annotations:
      ad.datadoghq.com/tidb.check_names: '["prometheus"]'
      ad.datadoghq.com/tidb.init_configs: '[{}]'
      ad.datadoghq.com/tidb.instances: '[{"prometheus_url": "http://%%host%%:10080/metrics", "namespace": "tidb_tidb", "metrics": ["tidb_server_connections", "tidb_server_handle_query_duration_seconds*", "tidb_session_transaction_duration_seconds*", "tidb_executor_statement_total", "tidb_server_query_total"]}]'
    topologySpreadConstraints:
    - topologyKey: kubernetes.io/hostname
      maxSkew: 1
      whenUnsatisfiable: DoNotSchedule
