apiVersion: pingcap.com/v1alpha1
kind: TidbCluster
metadata:
    labels:
        app.kubernetes.io/managed-by: test-infra
        # https://docs.pingcap.com/tidb-in-kubernetes/dev/deploy-multiple-tidb-operator
        user: test-infra
spec:
    schedulerName: default-scheduler
    imagePullPolicy: Always
    pvReclaimPolicy: Delete
    # delete the pvc(and so on reclaim the pv it bounds) when scale-in to release pv quickly
    # side effects: log data will also be deleted(it's acceptable because of the pod has been deleted)
    enablePVReclaim: true
    configUpdateStrategy: RollingUpdate
    timezone: UTC
    # tolerate test-infra dedicated nodes
    tolerations:
        - effect: NoSchedule
          key: dedicated
          operator: Equal
          value: test-infra
    # annotate managed by test-infra for fluent-bit log scraping
    annotations:
        app.kubernetes.io/managed-by: test-infra
    helper:
        # uses busybox:1.33.0 because of multi-arch support reason
        image: registry-mirror.pingcap.net/library/busybox:1.33.0
    version: master
    pd:
        # Access TiDB Dashboard by port forward
        enableDashboardInternalProxy: true
        baseImage: "pingcap/pd"
        replicas: 1
        requests:
            storage: 10Gi
            cpu: 250m
            memory: 256Mi
        limits:
            cpu: 4000m
            memory: 8Gi
        dataSubDir: data
        # Although image deploy with prod build(no enable-failpoint), set GO_FAILPOINTS also may result in performance regression
        #        env:
        #            - name: GO_FAILPOINTS
        #              value: github.com/tikv/pd/server/api/enableFailpointAPI=return
        storageVolumes:
            # this will be suffix of PVC names in VolumeClaimTemplates of PD StatefulSet
            - name: log
              # specify this to use special storageClass for this volume, default to component-level `storageClassName`
              storageClassName: local-path
              # storage request of PVC
              storageSize: 10Gi
              # mount path of the PVC
              mountPath: /var/lib/pd/log
        config:
            log:
                file:
                    filename: /var/lib/pd/log/pd.log
    tikv:
        baseImage: "pingcap/tikv"
        replicas: 1
        requests:
            storage: 40Gi
            cpu: 500m
            memory: 1Gi
        limits:
            cpu: 8000m
            memory: 16Gi
        dataSubDir: data
        storageVolumes:
            - name: log
              storageClassName: local-path
              storageSize: 10Gi
              mountPath: /var/lib/tikv/log
        config:
            storage:
                reserve-space: 0MB
            log-file: /var/lib/tikv/log/tikv.log
    tidb:
        separateSlowLog: false
        baseImage: "pingcap/tidb"
        replicas: 1
        requests:
            cpu: 500m
            memory: 512Mi
        limits:
            cpu: 8000m
            memory: 16Gi
        config:
            log:
                file:
                    filename: /var/lib/tidb/log/tidb.log
                slow-query-file: "/var/lib/tidb/log/slowquery" # not ends with .log because it's not a typical log file, format can't be handled by fluent-bit
        storageVolumes:
            - name: log
              storageClassName: local-path
              storageSize: 10Gi
              mountPath: /var/lib/tidb/log
        service:
            type: NodePort
    # Although image deploy with prod build(no enable-failpoint), set GO_FAILPOINTS also may result in performance regression
    #        env:
    #            - name: GO_FAILPOINTS
    #              value: github.com/pingcap/tidb/server/enableTestAPI=return
    ticdc:
        baseImage: "pingcap/ticdc"
        replicas: 0
        requests:
            cpu: 250m
            memory: 256Mi
        limits:
            cpu: 4000m
            memory: 8Gi
        # tidb-operator 1.2.0-rc.2's feature: https://github.com/pingcap/tidb-operator/pull/4004
        storageVolumes:
            - name: log
              storageClassName: local-path
              storageSize: 10Gi
              mountPath: /var/lib/ticdc/log
            - name: data
              storageSize: 500Gi
              mountPath: /tmp
        config:
            log-file: /var/lib/ticdc/log/ticdc.log
    tiflash:
        baseImage: "pingcap/tiflash"
        replicas: 0
        requests:
            cpu: 500m
            memory: 1Gi
        limits:
            cpu: 8000m
            memory: 16Gi
        storageClaims:
            - resources:
                  requests:
                      storage: 40Gi
