Deploy TiFlash on Kubernetes

This document describes how to deploy TiFlash on Kubernetes.

Prerequisites

Fresh TiFlash deployment

To deploy TiFlash when deploying the TiDB cluster, refer to Deploy TiDB on General Kubernetes.

Add TiFlash component to an existing TiDB cluster

Edit TidbCluster Custom Resource:

kubectl eidt tc ${cluster_name} -n ${namespace}

Add the TiFlash configuration as follows:

spec:
  tiflash:
    baseImage: pingcap/tiflash
    maxFailoverCount: 3
    replicas: 1
    storageClaims:
    - resources:
        requests:
          storage: 100Gi
      storageClassName: local-storage

TiFlash supports mounting multiple Persistent Volumes (PVs). If you want to configure multiple PVs for TiFlash, configure multiple resources in tiflash.storageClaims, each resources with a separate storage request and storageClassName. For example:

  tiflash:
    baseImage: pingcap/tiflash
    maxFailoverCount: 3
    replicas: 1
    storageClaims:
    - resources:
        requests:
          storage: 100Gi
      storageClassName: local-storage
    - resources:
        requests:
          storage: 100Gi
      storageClassName: local-storage

To add TiFlash component to an existing TiDB cluster, replication.enable-placement-rules should be set to true in PD. After you add the TiFlash configuration in TidbCluster by taking the above steps, TiDB Operator will automatically configure replication.enable-placement-rules: "true" in PD.