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.23k stars 498 forks source link

TIDB: Support for attaching storage volumes to tidb statefulset in kubernetes #3442

Closed venkatvghub closed 4 years ago

venkatvghub commented 4 years ago

Feature Request

Is your feature request related to a problem? Please describe:

Currently, in a cloud environment with tidb running on kubernetes, the logs are getting printed to stdout. In general, increased log volume poses significant IOPS issues in certain cloud environments. Esp, since the stdout is mapped to root volumes and in homogeneous infrastructure, doing specific IOPS provisioning of these nodes becomes challenging. In essence, we would need a way to do 2 things:

  1. Ability to write the tidb log files to a separate file besides stdout/stderrr (This capability already exists)
  2. Ability to attach a PV/PVC to the tidb statefulset which can be mounted for writing the above file.

Describe the feature you'd like:

A kubernetes config for tidb sts typically looks like the following:

tidb:
....
  config:
      log-file: /var/log/tidb/tidb.log ## Log file path where its being written. 
      log-level: warn
      log-rotation-size: 300MB
      log-rotation-timespan: 24h

We would like to attach a PV to the tidb sts to actually mount /var/log/tidb path to the PV in the above example. The current tidb crds or operator doesn't have this option. Ref: https://tidbcommunity.slack.com/archives/CH7TTLL7P/p1603954421124000 Describe alternatives you've considered:

  1. We need to be able to attach a disk at the node level. But this looks cumbersome in cloud environments.
  2. Moved the log level from info to warn, but that only looks like postphoning the problem, in case the warn logs increase.

Teachability, Documentation, Adoption, Migration Strategy:

  1. Update the CRD / Operator for the above
  2. Update the documentation for tidb with options to attach storageclassName and storageclassClaims.
mikechengwei commented 4 years ago

Now , we support tikv mount multiple pv, ref: https://github.com/pingcap/tidb-operator/blob/master/examples/multiple-pv-tikv/tidb-cluster.yaml. Pd and tidb nodetype are calculation types, do they need to support this function?

mikechengwei commented 4 years ago

And I have submitted storageVolumes PR for PD and TIDB.