跳到主要内容
版本:1.0

GreptimeDB Operator 的管理

GreptimeDB Operator 使用 Operator 模式 在 Kubernetes 上管理 GreptimeDB 资源。

就像自动驾驶一样,GreptimeDB Operator 自动化了 GreptimeDB 集群和单机实例的部署、配置和管理。

GreptimeDB Operator 包括但不限于以下功能:

  • 自动化部署: 通过提供 GreptimeDBCluster 和 GreptimeDBStandalone CRD 来自动化在 Kubernetes 上部署 GreptimeDB 集群和单机实例。

  • 多云支持: 用户可以在任何 Kubernetes 集群上部署 GreptimeDB,包括私有环境和公有云环境(如 AWS、GCP、阿里云等)。

  • 扩缩容: 通过修改 GreptimeDBCluster CR 中的 replicas 字段即可轻松实现 GreptimeDB 集群的扩缩容。

  • 监控: 通过在 GreptimeDBCluster CR 中提供 monitoring 字段来自动化部署基于 GreptimeDB 的监控组件。

本指南将展示如何在 Kubernetes 上安装、升级、配置和卸载 GreptimeDB Operator。

备注

以下输出可能会因 Helm chart 版本和具体环境的不同而有细微差别。

前置依赖​

  • Kubernetes >= v1.18.0
  • kubectl >= v1.18.0
  • Helm >= v3.0.0

生产环境部署​

对于生产环境部署,推荐使用 Helm 来安装 GreptimeDB Operator。

安装​

你可以参考 安装和验证 GreptimeDB Operator 获取详细的指导。

备注

如果你使用 Argo CD 来部署应用,请确保 Application 已设置 ServerSideApply=true 以启用 server-side apply(其他 GitOps 工具可能也有类似的设置)。

升级​

我们总是将最新版本的 GreptimeDB Operator 作为 Helm chart 发布在我们的官方 Helm 仓库。

当最新版本的 GreptimeDB Operator 发布时,您可以通过运行以下命令来升级 GreptimeDB Operator。

更新 Helm 仓库​

helm repo update greptime
期望输出
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "greptime" chart repository
Update Complete. ⎈Happy Helming!⎈

你可以使用以下命令来搜索 GreptimeDB Operator 的最新版本:

helm search repo greptime/greptimedb-operator
预期输出
NAME                             CHART VERSION   APP VERSION     DESCRIPTION
greptime/greptimedb-operator 0.5.9 0.5.5 The greptimedb-operator Helm chart for Kubernetes.

如果你想列出所有可用的版本,你可以使用以下命令:

helm search repo greptime/greptimedb-operator --versions

升级 GreptimeDB Operator​

你可以通过运行以下命令升级到最新发布的 GreptimeDB Operator 版本:

helm -n greptimedb-admin upgrade --install greptimedb-operator greptime/greptimedb-operator
期望输出
NAME: greptimedb-operator
LAST DEPLOYED: Sun Apr 26 20:43:58 2026
NAMESPACE: greptimedb-admin
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
***********************************************************************
Welcome to use greptimedb-operator
Chart version: 0.5.9
GreptimeDB Operator version: 0.5.5
***********************************************************************

Installed components:
* greptimedb-operator

The greptimedb-operator is starting, use `kubectl get deployment greptimedb-operator -n greptimedb-admin` to check its status.

如果你想升级到特定版本,你可以使用以下命令:

helm -n greptimedb-admin upgrade --install greptimedb-operator greptime/greptimedb-operator --version <version>

升级完成后,你可以使用以下命令来验证安装:

helm list -n greptimedb-admin
期望输出
NAME                     NAMESPACE               REVISION        UPDATED                                 STATUS          CHART                           APP VERSION
greptimedb-operator greptimedb-admin 1 2026-04-26 20:43:58.003167 +0800 CST deployed greptimedb-operator-0.5.9 0.5.5

CRDs​

这里将有两种类型的 CRD 与 GreptimeDB Operator 一起安装:GreptimeDBCluster 和 GreptimeDBStandalone。

你可以使用以下命令来验证安装:

kubectl get crd | grep greptime
期望输出
greptimedbclusters.greptime.io      2026-04-26T12:43:58Z
greptimedbstandalones.greptime.io 2026-04-26T12:43:58Z

默认情况下,GreptimeDB Operator chart 将管理 CRDs 的安装和升级,用户不需要手动管理它们。如果你想了解这两类 CRD 的具体定义,可参考 GreptimeDB Operator 的 API 文档。

配置​

GreptimeDB Operator chart 提供了一组配置选项,允许您自行配置,您可以参考 GreptimeDB Operator Helm Chart 来获取更多详细信息。

你可以创建一个 values.yaml 来配置 GreptimeDB Operator chart (完整的 values.yaml 配置可以参考 chart),例如:

image:
# -- The image registry
registry: docker.io
# -- The image repository
repository: greptime/greptimedb-operator
# -- The image pull policy for the controller
imagePullPolicy: IfNotPresent
# -- The image tag
tag: "v0.6.1"
# -- The image pull secrets
pullSecrets: []

replicas: 1

resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 250m
memory: 256Mi
备注

中国大陆用户如有网络访问问题,可将上文中的 image.registry 配置为阿里云镜像仓库地址 greptime-registry.cn-hangzhou.cr.aliyuncs.com。

你可以使用以下的命令来安装或升级带有自定义配置的 GreptimeDB Operator:

helm -n greptimedb-admin upgrade --install greptimedb-operator greptime/greptimedb-operator -f values.yaml

卸载​

你可以使用 helm 命令来卸载 GreptimeDB Operator:

helm -n greptimedb-admin uninstall greptimedb-operator

默认情况下,卸载 GreptimeDB Operator 时不会删除 CRDs。

危险

如果你确实想要删除 CRDs,你可以使用以下命令:

kubectl delete crd greptimedbclusters.greptime.io greptimedbstandalones.greptime.io

删除 CRDs 后,相关资源将被删除。