常见 Helm Chart 配置项
对于每一个 Helm Chart,你都可以通过创建 values.yaml 来进行配置。当你需要应用配置时,你可以通过 helm upgrade 命令来应用配置:
1. helm upgrade --install ${release-name} ${chart-name} --namespace ${namespace} -f values.yaml
GreptimeDB Cluster Chart
完整的配置项可参考 GreptimeDB Cluster Chart。
GreptimeDB 运行镜像配置
顶层变量 image 用于配置集群全局的运行镜像,如下所示:
1. image:
2. # -- The image registry
3. registry: greptime-registry.cn-hangzhou.cr.aliyuncs.com
4. # -- The image repository
5. repository: greptime/greptimedb
6. # -- The image tag
7. tag: "v0.11.3"
8. # -- The image pull secrets
9. pullSecrets: []
如果你想为集群中的每个 Role 配置不同的镜像,可以使用 ${role}.podTemplate.main.image 字段(其中 role 可以是 meta、frontend、datanode 和 flownode),该字段会覆盖顶层变量 image 的配置,如下所示:
1. image:
2. # -- The image registry
3. registry: greptime-registry.cn-hangzhou.cr.aliyuncs.com
4. # -- The image repository
5. repository: greptime/greptimedb
6. # -- The image tag
7. tag: "v0.11.3"
8. # -- The image pull secrets
9. pullSecrets: []
11. frontend:
12. podTemplate:
13. main:
14. image: "greptime-registry.cn-hangzhou.cr.aliyuncs.com/greptime/greptimedb:latest"
此时 frontend 的镜像将会被设置为 greptime-registry.cn-hangzhou.cr.aliyuncs.com/greptime/greptimedb:latest,而其他组件的镜像将会使用顶层变量 image 的配置。
服务端口配置
你可以使用如下字段来配置服务端口,如下所示:
httpServicePort: 用于配置 HTTP 服务的端口,默认 4000;grpcServicePort: 用于配置 SQL 服务的端口,默认 4001;mysqlServicePort: 用于配置 MySQL 服务的端口,默认 4002;postgresServicePort: 用于配置 PostgreSQL 服务的端口,默认 4003;
Datanode 存储配置
你可以通过 datanode.storage 字段来配置 Datanode 的存储,如下所示:
1. datanode:
2. storage:
3. # -- Storage class for datanode persistent volume
4. storageClassName: null
5. # -- Storage size for datanode persistent volume
6. storageSize: 10Gi
7. # -- Storage retain policy for datanode persistent volume
8. storageRetainPolicy: Retain
9. # -- The dataHome directory, default is "/data/greptimedb/"
10. dataHome: "/data/greptimedb"
storageClassName: 用于配置 StorageClass,默认使用 Kubernetes 当前默认的 StorageClass;storageSize: 用于配置 Storage 的大小,默认 10Gi。你可以使用常用的容量单位,如10Gi、10GB等;storageRetainPolicy: 用于配置 Storage 的保留策略,默认Retain,如果设置为Delete,则当集群被删除时,相应的 Storage 也会被删除;dataHome: 用于配置数据目录,默认/data/greptimedb/;
运行资源配置
顶层变量 base.podTemplate.main.resources 用于全局配置每个 Role 的资源,如下所示:
1. base:
2. podTemplate:
3. main:
4. resources:
5. requests:
6. memory: "1Gi"
7. cpu: "1"
8. limits:
9. memory: "2Gi"
10. cpu: "2"
如果你想为集群中的每个 Role 配置不同的资源,可以使用 ${role}.podTemplate.main.resources 字段(其中 role 可以是 meta、frontend、datanode 等),改字段会覆盖顶层变量 base.podTemplate.main.resources 的配置,如下所示:
1. base:
2. podTemplate:
3. main:
4. resources:
5. requests:
6. memory: "1Gi"
7. cpu: "1"
8. limits:
9. memory: "2Gi"
10. cpu: "2"
12. frontend:
13. podTemplate:
14. main:
15. resources:
16. requests:
17. cpu: "2"
18. memory: "4Gi"
19. limits:
20. cpu: "4"
21. memory: "8Gi"
服务运行副本数配置
对于不同 Role 的副本数,可以通过 ${role}.replicas 字段进行配置对应的副本数,如下所示:
1. frontend:
2. replicas: 3
4. datanode:
5. replicas: 3
你可以通过配置其副本数来实现水平扩缩。
环境变量配置
你既可以通过 base.podTemplate.main.env 字段配置全局的环境变量,也可以通过 ${role}.podTemplate.main.env 字段为每个 Role 配置不同的环境变量,如下所示:
1. base:
2. podTemplate:
3. main:
4. env:
5. - name: GLOBAL_ENV
6. value: "global_value"
8. frontend:
9. podTemplate:
10. main:
11. env:
12. - name: FRONTEND_ENV
13. value: "frontend_value"
注入配置文件
对于不同 Role 的服务,你可以通过 ${role}.configData 字段注入自定义的 TOML 配置文件,如下所示:
1. frontend:
2. configData: |
3. [[region_engine]]
4. [region_engine.mito]
5. # Number of region workers
6. num_workers = 8
你可以通过 config.md 了解 GreptimeDB 的配置项。
除了使用 ${role}.configData 字段注入配置文件,你还可以通过 ${role}.configFile 来指定相应的文件,如下所示:
1. frontend:
2. configFile: "configs/frontend.toml"
此时需要确保对应的配置文件路径与执行 helm upgrade 命令时所处的目录一致。
备注
用户注入的配置文件默认优先级低于由 GreptimeDB Operator 所接管的配置项,某些配置项仅能通过 GreptimeDB Operator 进行配置,而这些配置项默认会暴露在 values.yaml 中。
如下默认配置将由 GreptimeDB Operator 管理:
- Logging 配置;
- Datanode 的 Node ID;
鉴权配置
Helm Chart 默认不启用 User Provider 模式的鉴权,你可以通过 auth.enabled 字段启用 User Provider 模式的鉴权并配置相应的用户信息,如下所示:
1. auth:
2. enabled: true
3. users:
4. - name: "admin"
5. password: "admin"
日志配置
顶层变量 logging 用于配置全局日志级别,如下所示:
1. # -- Global logging configuration
2. logging:
3. # -- The log level for greptimedb, only support "debug", "info", "warn", "debug"
4. level: "info"
6. # -- The log format for greptimedb, only support "json" and "text"
7. format: "text"
9. # -- The logs directory for greptimedb
10. logsDir: "/data/greptimedb/logs"
12. # -- Whether to log to stdout only
13. onlyLogToStdout: false
15. # -- indicates whether to persist the log with the datanode data storage. It **ONLY** works for the datanode component.
16. persistentWithData: false
18. # -- The log filters, use the syntax of `target[span\{field=value\}]=level` to filter the logs.
19. filters: []
21. # -- The slow query log configuration.
22. slowQuery:
23. # -- Enable slow query log.
24. enabled: false
26. # -- The threshold of slow query log in seconds.
27. threshold: "10s"
29. # -- Sample ratio of slow query log.
30. sampleRatio: "1.0"
其中:
logging.level: 用于配置全局日志级别,支持debug、info、warn、error四个级别;logging.format: 用于配置全局日志格式,支持json和text两种格式;logging.logsDir: 用于配置全局日志目录,默认位于/data/greptimedb/logs;logging.onlyLogToStdout: 用于配置是否仅输出到标准输出,默认不启用;logging.persistentWithData: 用于配置是否将日志持久化到数据存储,仅适用于datanode组件,默认不启用;logging.filters: 用于配置全局日志过滤器,支持target[span\{field=value\}]=level的语法,特步地,如果你希望对某些组件启动debug级别的日志,可以配置如下:
1. logging:
2. level: "info"
3. format: "json"
4. filters:
5. - mito2=debug
你还可以通过 logging.slowQuery 字段配置来启用慢查询日志,如下所示:
1. logging:
2. slowQuery:
3. enabled: true
4. threshold: "100ms"
5. sampleRatio: "1.0"
其中:
logging.slowQuery.enabled: 用于配置是否启用慢查询日志,默认不启用;logging.slowQuery.threshold: 用于配置慢查询日志的阈值;logging.slowQuery.sampleRatio: 用于配置慢查询日志的采样率,默认 1.0(即全部采样);
如果配置了输出目录 logging.logsDir,则慢查询日志会输出到该目录下。
每一个 Role 的日志配置都可以通过 ${role}.logging 字段进行配置,其字段与顶层 logging 一致,并会覆盖顶层变量 logging 的配置,比如:
1. frontend:
2. logging:
3. level: "debug"
启用 Flownode
Helm Chart 默认不启用 Flownode,你可以通过 flownode.enabled 字段启用 Flownode,如下所示:
1. flownode:
2. enabled: true
flownode 的其他字段的配置与其他 Role 的配置一致,比如:
1. flownode:
2. enabled: true
3. replicas: 1
4. podTemplate:
5. main:
6. resources:
7. requests:
8. memory: "1Gi"
9. cpu: "1"
10. limits:
11. memory: "2Gi"
12. cpu: "2"
对象存储配置
objectStorage 字段用于配置云对象存储(例如 AWS S3 和 Azure Blob Storage 等)作为 GreptimeDB 存储层。
AWS S3
1. objectStorage:
2. credentials:
3. # AWS access key ID
4. accessKeyId: ""
5. # AWS secret access key
6. secretAccessKey: ""
7. s3:
8. # AWS S3 bucket name
9. bucket: ""
10. # AWS S3 region
11. region: ""
12. # The root path in bucket is 's3://<bucket>/<root>/data/...'
13. root: ""
14. # The AWS S3 endpoint, see more detail: https://docs.aws.amazon.com/general/latest/gr/s3.html
15. endpoint: ""
Google Cloud Storage
1. objectStorage:
2. credentials:
3. # GCP serviceAccountKey JSON-formatted base64 value
4. serviceAccountKey: ""
5. gcs:
6. # Google Cloud Storage bucket name
7. bucket: ""
8. # Google Cloud OAuth 2.0 Scopes, example: "https://www.googleapis.com/auth/devstorage.read_write"
9. scope: ""
10. # The root path in bucket is 'gcs://<bucket>/<root>/data/...'
11. root: ""
12. # Google Cloud Storage endpoint, example: "https://storage.googleapis.com"
13. endpoint: ""
Azure Blob
1. objectStorage:
2. credentials:
3. # Azure account name
4. accountName: ""
5. # Azure account key
6. accountKey: ""
7. azblob:
8. # Azure Blob container name
9. container: ""
10. # The root path in container is 'blob://<bucket>/<root>/data/...'
11. root: ""
12. # Azure Blob endpoint, see: "https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-query-endpoint-srp?tabs=dotnet#query-for-the-blob-storage-endpoint"
13. endpoint: ""
AliCloud OSS
1. objectStorage:
2. credentials:
3. # AliCloud access key ID
4. accessKeyId: ""
5. # AliCloud access key secret
6. secretAccessKey: ""
7. oss:
8. # AliCloud OSS bucket name
9. bucket: ""
10. # AliCloud OSS region
11. region: ""
12. # The root path in bucket is 'oss://<bucket>/<root>/data/...'
13. root: ""
14. # The AliCloud OSS endpoint
15. endpoint: ""
Prometheus 监控配置
如果你已经安装了 prometheus-operator,你可以通过 prometheusMonitor.enabled 字段创建 Prometheus PodMonitor 来监控 GreptimeDB,如下所示:
1. prometheusMonitor:
2. # -- Create PodMonitor resource for scraping metrics using PrometheusOperator
3. enabled: false
4. # -- Interval at which metrics should be scraped
5. interval: "30s"
6. # -- Add labels to the PodMonitor
7. labels:
8. release: prometheus
Debug Pod 配置
debug pod 中安装了各种工具(例如 mysql-client、psql-client 等)。你可以 exec 进入调试 debug pod 进行调试。使用 debugPod.enabled 字段创建它,如下所示:
1. debugPod:
2. # -- Enable debug pod
3. enabled: false
5. # -- The debug pod image
6. image:
7. registry: docker.io
8. repository: greptime/greptime-tool
9. tag: "20241107-9c210d18"
11. # -- The debug pod resource
12. resources:
13. requests:
14. memory: 64Mi
15. cpu: 50m
16. limits:
17. memory: 256Mi
18. cpu: 200m
