# Default values for tidb-cluster.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

# Also see monitor.serviceAccount
# If you set rbac.create to false, you need to provide a value for monitor.serviceAccount
rbac:
  create: true

# clusterName is the TiDB cluster name, if not specified, the chart release name will be used
clusterName: [[ .Name ]]

# Add additional TidbCluster labels
# ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
extraLabels: {}

# schedulerName must be same with charts/tidb-operator/values#scheduler.schedulerName
schedulerName: tidb-scheduler

# timezone is the default system timzone for TiDB
timezone: UTC

# default reclaim policy of a PV
pvReclaimPolicy: Delete

# services is the service list to expose, default is ClusterIP
# can be ClusterIP | NodePort | LoadBalancer
services:
  - name: pd
    type: ClusterIP

discovery:
  image: pingcap/tidb-operator:v1.0.0-beta.2
  imagePullPolicy: IfNotPresent
  resources:
    limits:
      cpu: 250m
      memory: 150Mi
    requests:
      cpu: 80m
      memory: 50Mi

# Whether enable ConfigMap Rollout management.
# When enabling, change of ConfigMap will trigger a graceful rolling-update of the component.
# This feature is only available in tidb-operator v1.0 or higher.
# Note: Switch this variable against an existing cluster will cause an rolling-update of each component even
# if the ConfigMap was not changed.
enableConfigMapRollout: false

pd:
  replicas: [[ .Spec.PD.Replicas ]]
  image: [[ .Spec.PD.Image ]]
  [[ $pdLogLevel := .PDConfig.LogLevel ]]
  [[ if .PDConfig.LogLevel ]]
  logLevel: [[ $pdLogLevel ]][[ end ]]
  [[ $pdConfigContent := .PDConfig.Content ]]
  [[ if .PDConfig.Content ]]
  config: |-
[[ $pdConfigContent | indent 6 ]]
  [[ end ]]
  [[ if .PDConfig.Args ]]
  args: [[ .PDConfig.Args ]]
  [[ end ]]

  # storageClassName is a StorageClass provides a way for administrators to describe the "classes" of storage they offer.
  # different classes might map to quality-of-service levels, or to backup policies,
  # or to arbitrary policies determined by the cluster administrators.
  # refer to https://kubernetes.io/docs/concepts/storage/storage-classes
  storageClassName: [[ .Spec.PD.StorageClassName ]]

  # maxStoreDownTime is how long a store will be considered `down` when disconnected
  # if a store is considered `down`, the regions will be migrated to other stores
  maxStoreDownTime: 1h
  # maxReplicas is the number of replicas for each region
  maxReplicas: 3
  affinity: {}
  resources:
    # limits:
    #   cpu: 8000m
    #   memory: 8Gi
    limits:
      cpu: "[[ .Spec.PD.Limits.CPU ]]"
      memory: [[ .Spec.PD.Limits.Memory ]]
    requests:
      # cpu: 4000m
      # memory: 4Gi
      cpu: "[[ .Spec.PD.Requests.CPU ]]"
      memory: [[ .Spec.PD.Requests.Memory ]]
      storage: 1Gi
  # nodeSelector is used for scheduling pod,
  # if nodeSelectorRequired is true, all the following labels must be matched
  nodeSelectorRequired: [[ .Spec.PD.NodeSelectorRequired ]]
  [[ if ge (len .Spec.PD.NodeSelector) 0 ]]
  nodeSelector: [[ range $key, $value := .Spec.PD.NodeSelector ]]
    [[ $key ]]: [[ $value ]][[ end ]]
  [[else]]
  nodeSelector: {}
  [[ end ]]
  # nodeSelector: {}
    # kind: pd
    # # zone is comma separated availability zone list
    # zone: cn-bj1-01,cn-bj1-02
    # # region is comma separated region list
    # region: cn-bj1
  # Tolerations are applied to pods, and allow pods to schedule onto nodes with matching taints.
  # refer to https://kubernetes.io/docs/concepts/configuration/taint-and-toleration
  tolerations: {}
  # - key: node-role
  #   operator: Equal
  #   value: tidb
  #   effect: "NoSchedule"
  annotations: {}

tikv:
  replicas: [[ .Spec.TiKV.Replicas ]]
  image: [[ .Spec.TiKV.Image ]]
  [[ $tikvLogLevel := .TiKVConfig.LogLevel ]]
  [[ if .TiKVConfig.LogLevel ]]
  logLevel: [[ $tikvLogLevel ]][[ end ]]
  [[ $tikvConfigContent := .TiKVConfig.Content ]]
  [[ if .TiKVConfig.Content ]]
  config: |-
[[ $tikvConfigContent | indent 6]]
  [[ end ]]
  [[ if .TiKVConfig.Args ]]
  args: [[ .TiKVConfig.Args ]]
  [[ end ]]

  # storageClassName is a StorageClass provides a way for administrators to describe the "classes" of storage they offer.
  # different classes might map to quality-of-service levels, or to backup policies,
  # or to arbitrary policies determined by the cluster administrators.
  # refer to https://kubernetes.io/docs/concepts/storage/storage-classes
  storageClassName: [[ .Spec.TiKV.StorageClassName ]]

  # syncLog is a bool value to enable or disable syc-log for raftstore, default is true
  # enable this can prevent data loss when power failure
  syncLog: true
  affinity: {}
  resources:
    limits:
      cpu: "[[ .Spec.TiKV.Limits.CPU ]]"
      memory: [[ .Spec.TiKV.Limits.Memory ]]
    requests:
      # cpu: 4000m
      # memory: 4Gi
      cpu: "[[ .Spec.TiKV.Requests.CPU ]]"
      memory: [[ .Spec.TiKV.Requests.Memory ]]
      storage: 10Gi
    # limits:
    #   cpu: 16000m
    #   memory: 32Gi
    #   storage: 300Gi
    #requests:
      # cpu: 12000m
      # memory: 24Gi
  nodeSelectorRequired: [[ .Spec.TiKV.NodeSelectorRequired ]]
  [[ if ge (len .Spec.TiKV.NodeSelector) 0 ]]
  nodeSelector: [[ range $key, $value := .Spec.TiKV.NodeSelector ]]
    [[ $key ]]: [[ $value ]][[ end ]]
  [[else]]
  nodeSelector: {}
  [[ end ]]
    # kind: tikv
    # zone: cn-bj1-01,cn-bj1-02
    # region: cn-bj1
  tolerations: {}
  # - key: node-role
  #   operator: Equal
  #   value: tidb
  #   effect: "NoSchedule"
  annotations: {}

  # block-cache used to cache uncompressed blocks, big block-cache can speed up read.
  # in normal cases should tune to 30%-50% tikv.resources.limits.memory
  # defaultcfBlockCacheSize: "1GB"

  # in normal cases should tune to 10%-30% tikv.resources.limits.memory
  # writecfBlockCacheSize: "256MB"

  # size of thread pool for high-priority/normal-priority/low-priority operations
  # readpoolStorageConcurrency: 4

  # Notice: if tikv.resources.limits.cpu > 8, default thread pool size for coprocessors
  # will be set to tikv.resources.limits.cpu * 0.8.
  # readpoolCoprocessorConcurrency: 8

  # scheduler's worker pool size, should increase it in heavy write cases,
  # also should less than total cpu cores.
  # storageSchedulerWorkerPoolSize: 4

tidb:
  replicas: [[ .Spec.TiDB.Replicas ]]
  image: [[ .Spec.TiDB.Image ]]
  [[ $tidbLogLevel := .TiDBConfig.LogLevel ]]
  [[ if .TiDBConfig.LogLevel ]]
  logLevel: [[ $tidbLogLevel ]][[ end ]]
  [[ $tidbConfigContent := .TiDBConfig.Content ]]
  [[ if .TiDBConfig.Content ]]
  config: |-
[[ $tidbConfigContent | indent 6]]
  [[ end ]]
  [[ if .TiDBConfig.Args ]]
  args: [[ .TiDBConfig.Args ]]
  [[ end ]]

  affinity: {}
  resources:
    # limits:
    #   cpu: 16000m
    #   memory: 16Gi
    # requests:
    #   cpu: 12000m
    #   memory: 12Gi
    limits:
      cpu: "[[ .Spec.TiDB.Limits.CPU ]]"
      memory: "[[ .Spec.TiDB.Limits.Memory ]]"
    requests:
      # cpu: 4000m
      # memory: 4Gi
      cpu: "[[ .Spec.TiDB.Requests.CPU ]]"
      memory: [[ .Spec.TiDB.Requests.Memory ]]
    # kind: tidb
    # zone: cn-bj1-01,cn-bj1-02
    # region: cn-bj1
  nodeSelectorRequired: [[ .Spec.TiDB.NodeSelectorRequired ]]
  [[ if ge (len .Spec.TiDB.NodeSelector) 0 ]]
  nodeSelector: [[ range $key, $value := .Spec.TiDB.NodeSelector ]]
    [[ $key ]]: [[ $value ]][[ end ]]
  [[else]]
  nodeSelector: {}
  [[ end ]]
  tolerations: {}
  # - key: node-role
  #   operator: Equal
  #   value: tidb
  #   effect: "NoSchedule"
  service:
    type: NodePort
    exposeStatus: true
    annotations: {}
      # cloud.google.com/load-balancer-type: Internal
  # separateSlowLog: true
  slowLogTailer:
    image: busybox:1.26.2
    resources:
      limits:
        cpu: 100m
        memory: 50Mi
      requests:
        cpu: 20m
        memory: 5Mi

  # tidb plugin configuration
  plugin:
    # enable plugin or not
    enable: false
    # the start argument to specify the folder containing
    directory: /plugins
    # the start argument to specify the plugin id (name "-" version) that needs to be loaded, e.g. 'conn_limit-1'.
    list: ["whitelist-1"]

# mysqlClient is used to set password for TiDB
# it must has Python MySQL client installed
mysqlClient:
  image: tnir/mysqlclient
  imagePullPolicy: IfNotPresent

monitor:
  create: true
  # Also see rbac.create
  # If you set rbac.create to false, you need to provide a value here.
  # If you set rbac.create to true, you should leave this empty.
  # serviceAccount:
  persistent: false
  storageClassName: local-storage
  storage: 10Gi
  grafana:
    create: true
    image: grafana/grafana:6.0.1
    imagePullPolicy: IfNotPresent
    logLevel: info
    resources:
      limits: {}
      #   cpu: 8000m
      #   memory: 8Gi
      requests: {}
      #   cpu: 4000m
      #   memory: 4Gi
    username: admin
    password: admin
    config:
      # Configure Grafana using environment variables except GF_PATHS_DATA, GF_SECURITY_ADMIN_USER and GF_SECURITY_ADMIN_PASSWORD
      # Ref https://grafana.com/docs/installation/configuration/#using-environment-variables
      GF_AUTH_ANONYMOUS_ENABLED: "true"
      GF_AUTH_ANONYMOUS_ORG_NAME: "Main Org."
      GF_AUTH_ANONYMOUS_ORG_ROLE: "Viewer"
      # if grafana is running behind a reverse proxy with subpath http://foo.bar/grafana
      # GF_SERVER_DOMAIN: foo.bar
      # GF_SERVER_ROOT_URL: "%(protocol)s://%(domain)s/grafana/"
    service:
      type: NodePort
  prometheus:
    image: prom/prometheus:v2.2.1
    imagePullPolicy: IfNotPresent
    logLevel: info
    resources:
      limits: {}
      #   cpu: 8000m
      #   memory: 8Gi
      requests: {}
      #   cpu: 4000m
      #   memory: 4Gi
    service:
      type: NodePort
    reserveDays: 12
    # alertmanagerURL: ""
  nodeSelector: {}
    # kind: monitor
    # zone: cn-bj1-01,cn-bj1-02
    # region: cn-bj1
  tolerations: []
  # - key: node-role
  #   operator: Equal
  #   value: tidb
  #   effect: "NoSchedule"

binlog:
  pump:
    create: false
    replicas: 1
    image: pingcap/tidb-binlog:v3.0.0-rc.1
    imagePullPolicy: IfNotPresent
    logLevel: info
    # storageClassName is a StorageClass provides a way for administrators to describe the "classes" of storage they offer.
    # different classes might map to quality-of-service levels, or to backup policies,
    # or to arbitrary policies determined by the cluster administrators.
    # refer to https://kubernetes.io/docs/concepts/storage/storage-classes
    storageClassName: local-storage
    storage: 10Gi
    syncLog: true
    # a integer value to control expiry date of the binlog data, indicates for how long (in days) the binlog data would be stored.
    # must bigger than 0
    gc: 7
    # number of seconds between heartbeat ticks (in 2 seconds)
    heartbeatInterval: 2

  drainer:
    create: false
    image: pingcap/tidb-binlog:v3.0.0-rc.1
    imagePullPolicy: IfNotPresent
    logLevel: info
    # storageClassName is a StorageClass provides a way for administrators to describe the "classes" of storage they offer.
    # different classes might map to quality-of-service levels, or to backup policies,
    # or to arbitrary policies determined by the cluster administrators.
    # refer to https://kubernetes.io/docs/concepts/storage/storage-classes
    storageClassName: local-storage
    storage: 10Gi
    # the number of the concurrency of the downstream for synchronization. The bigger the value,
    # the better throughput performance of the concurrency (16 by default)
    workerCount: 16
    # the interval time (in seconds) of detect pumps' status (default 10)
    detectInterval: 10
    # disbale detect causality
    disableDetect: false
    # disable dispatching sqls that in one same binlog; if set true, work-count and txn-batch would be useless
    disableDispatch: false
    # # disable sync these schema
    ignoreSchemas: "INFORMATION_SCHEMA,PERFORMANCE_SCHEMA,mysql,test"
    # if drainer donesn't have checkpoint, use initial commitTS to initial checkpoint
    initialCommitTs: 0
    # enable safe mode to make syncer reentrant
    safeMode: false
    # the number of SQL statements of a transaction that are output to the downstream database (20 by default)
    txnBatch: 20
    # downstream storage, equal to --dest-db-type
    # valid values are "mysql", "pb", "kafka"
    destDBType: pb
    mysql: {}
      # host: "127.0.0.1"
      # user: "root"
      # password: ""
      # port: 3306
      # # Time and size limits for flash batch write
      # timeLimit: "30s"
      # sizeLimit: "100000"
    kafka: {}
      # only need config one of zookeeper-addrs and kafka-addrs, will get kafka address if zookeeper-addrs is configed.
      # zookeeperAddrs: "127.0.0.1:2181"
      # kafkaAddrs: "127.0.0.1:9092"
      # kafkaVersion: "0.8.2.0"

scheduledBackup:
  create: false
  binlogImage: pingcap/tidb-binlog:v3.0.0-rc.1
  binlogImagePullPolicy: IfNotPresent
  # https://github.com/tennix/tidb-cloud-backup
  mydumperImage: pingcap/tidb-cloud-backup:latest
  mydumperImagePullPolicy: IfNotPresent
  # storageClassName is a StorageClass provides a way for administrators to describe the "classes" of storage they offer.
  # different classes might map to quality-of-service levels, or to backup policies,
  # or to arbitrary policies determined by the cluster administrators.
  # refer to https://kubernetes.io/docs/concepts/storage/storage-classes
  storageClassName: local-storage
  storage: 100Gi
  # https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/#schedule
  schedule: "0 0 * * *"
  # https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/#suspend
  suspend: false
  # https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/#jobs-history-limits
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1
  # https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/#starting-deadline
  startingDeadlineSeconds: 3600
  # https://github.com/maxbube/mydumper/blob/master/docs/mydumper_usage.rst#options
  options: "--chunk-filesize=100"
  # secretName is the name of the secret which stores user and password used for backup
  # Note: you must give the user enough privilege to do the backup
  # you can create the secret by:
  # kubectl create secret generic backup-secret --from-literal=user=root --from-literal=password=<password>
  secretName: backup-secret
  # backup to gcp
  gcp: {}
  # bucket: ""
  # secretName is the name of the secret which stores the gcp service account credentials json file
  # The service account must have read/write permission to the above bucket.
  # Read the following document to create the service account and download the credentials file as credentials.json:
  # https://cloud.google.com/docs/authentication/production#obtaining_and_providing_service_account_credentials_manually
  # And then create the secret by: kubectl create secret generic gcp-backup-secret --from-file=./credentials.json
  # secretName: gcp-backup-secret

  # backup to ceph object storage
  ceph: {}
  # endpoint: ""
  # bucket: ""
  # secretName is the name of the secret which stores ceph object store access key and secret key
  # You can create the secret by:
  # kubectl create secret generic ceph-backup-secret --from-literal=access_key=<access-key> --from-literal=secret_key=<secret-key>
  # secretName: ceph-backup-secret

metaInstance: "{{ $labels.instance }}"
metaType: "{{ $labels.type }}"
metaValue: "{{ $value }}"
