{"id":29571857,"url":"https://github.com/oceanbase/ob-operator","last_synced_at":"2026-01-16T06:16:19.755Z","repository":{"id":36968218,"uuid":"444720954","full_name":"oceanbase/ob-operator","owner":"oceanbase","description":"Kubernetes operator for OceanBase","archived":false,"fork":false,"pushed_at":"2025-07-18T09:22:15.000Z","size":20521,"stargazers_count":157,"open_issues_count":31,"forks_count":39,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-07-18T13:33:47.858Z","etag":null,"topics":["cloud","cloudnative","container","distributed-database","docker","kubernetes","kubernetes-operator","mysql","oceanbase","sql"],"latest_commit_sha":null,"homepage":"https://oceanbase.github.io/ob-operator/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oceanbase.png","metadata":{"files":{"readme":"README-CN.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-01-05T08:19:56.000Z","updated_at":"2025-07-18T09:22:19.000Z","dependencies_parsed_at":"2024-01-08T11:18:47.929Z","dependency_job_id":"8f9ccb1f-c4f1-48f7-845f-a5d2522d4018","html_url":"https://github.com/oceanbase/ob-operator","commit_stats":null,"previous_names":[],"tags_count":75,"template":false,"template_full_name":null,"purl":"pkg:github/oceanbase/ob-operator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oceanbase%2Fob-operator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oceanbase%2Fob-operator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oceanbase%2Fob-operator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oceanbase%2Fob-operator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oceanbase","download_url":"https://codeload.github.com/oceanbase/ob-operator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oceanbase%2Fob-operator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265889155,"owners_count":23844539,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloud","cloudnative","container","distributed-database","docker","kubernetes","kubernetes-operator","mysql","oceanbase","sql"],"created_at":"2025-07-19T04:36:21.015Z","updated_at":"2026-01-16T06:16:19.741Z","avatar_url":"https://github.com/oceanbase.png","language":"Go","readme":"# ob-operator\n\nob-operator 是满足 Kubernetes Operator 扩展范式的自动化工具，可以极大简化在 Kubernetes 上部署和管理 OceanBase 集群及相关资源的过程。\n\n[English version](./README.md) of this document is available.\n\n## 快速上手\n\n这部分以一个简单示例说明如何使用 ob-operator 快速部署 OceanBase 集群。\n\n### 前提条件\n\n开始之前请准备一套可用的 Kubernetes 集群，并且至少可以分配 2C, 10G 内存以及 100G 存储空间。\n\nob-operator 依赖 [cert-manager](https://cert-manager.io/docs/), cert-manager 的安装可以参考对应的[安装文档](https://cert-manager.io/docs/installation/)，如果您无法访问官方制品托管在 `quay.io` 镜像站的镜像，可通过下面的指令安装我们转托在 `docker.io` 中的制品：\n\n```shell\nkubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/stable/deploy/cert-manager.yaml\n```\n\n本例子中的 OceanBase 集群存储依赖 [local-path-provisioner](https://github.com/rancher/local-path-provisioner) 提供, 需要提前进行安装并确保其存储目的地有足够大的磁盘空间。如果您计划在生产环境部署，推荐使用其他的存储解决方案。我们在[存储兼容性](#存储兼容性)一节提供了我们测试过的存储兼容性结果。\n\n### 部署 ob-operator\n\n#### 使用 YAML 配置文件\n\n通过以下命令即可在 K8s 集群中部署 ob-operator：\n\n- 稳定版本\n\n```shell\nkubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/stable/deploy/operator.yaml\n```\n\n- 开发版本\n\n```shell\nkubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/master/deploy/operator.yaml\n```\n\n#### 使用 Helm Chart\n\nHelm Chart 将 ob-operator 部署的命名空间进行了参数化，可在安装 ob-operator 之前指定命名空间。\n\n```shell\nhelm repo add ob-operator https://oceanbase.github.io/ob-operator/\nhelm repo update\nhelm install ob-operator ob-operator/ob-operator --namespace=oceanbase-system --create-namespace\n```\n\n#### 使用 terraform\n\n部署所需要的文件放在项目的 `deploy/terraform` 目录\n\n1. 生成配置变量:\n   在开始部署前，需要通过以下命令来生成 `terraform.tfvars` 文件，用来记录当前 Kubernetes 集群的一些配置。\n\n```shell\ncd deploy/terraform\n./generate_k8s_cluster_tfvars.sh\n```\n\n2. 初始化 Terraform:\n   此步骤用来保证 terraform 获取到必要的 plugin 和模块来管理配置的资源，使用如下命令来进行初始化。\n\n```\nterraform init\n```\n\n3. 应用配置:\n   执行以下命令开始部署 ob-operator。\n\n```\nterraform apply\n```\n\n#### 使用命令行工具 (okctl)\n\n您还可以使用命令行工具 okctl 来部署 ob-operator，okctl 是可以用来部署 ob-operator 和管理 OceanBase 集群的方便的工具。\n\n你可以通过 releases 页面下载 CLI 工具，或者通过以下命令下载：\n\n```shell\n# 使用代理\ncurl -sL https://gh.wewell.org/https://github.com/oceanbase/ob-operator/blob/master/scripts/install-okctl.sh | bash -s -- --proxy\n\n# 不使用代理\ncurl -sL https://raw.githubusercontent.com/oceanbase/ob-operator/master/scripts/install-okctl.sh | bash\n```\n\n下载完成之后，可以通过以下命令来部署 ob-operator，\n\n```shell\n./okctl install\n```\n\n另外，我们推荐将 CLI 工具添加到 PATH 环境变量中，\n\n```shell\nmv ./okctl /usr/local/bin\n```\n\n#### 验证部署结果\n\n安装完成之后，可以使用以下命令验证 ob-operator 是否部署成功：\n\n```shell\nkubectl get pod -n oceanbase-system\n\n# 预期的输出\nNAME                                            READY   STATUS    RESTARTS   AGE\noceanbase-controller-manager-86cfc8f7bf-4hfnj   2/2     Running   0          1m\n```\n\n### 部署 OceanBase 集群\n\n创建 OceanBase 集群之前，需要先创建好若干 secret 来存储 OceanBase 中的特定用户的密码：\n\n```shell\nkubectl create secret generic root-password --from-literal=password='root_password'\n```\n\n通过以下命令即可在 K8s 集群中部署 OceanBase：\n\n```shell\nkubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/stable/example/quickstart/obcluster.yaml\n```\n\n一般初始化集群需要 2 分钟左右的时间，执行以下命令，查询集群状态，当集群状态变成 running 之后表示集群创建和初始化成功：\n\n```shell\nkubectl get obclusters.oceanbase.oceanbase.com test\n\n# desired output\nNAME   STATUS    AGE\ntest   running   6m2s\n```\n\n### 连接集群\n\n通过以下命令查找 observer 的 POD IP，POD 名的规则是 `${cluster_name}-${cluster_id}-${zone}-uuid`：\n\n```shell\nkubectl get pods -o wide\n```\n\n通过以下命令连接：\n\n```shell\nmysql -h{POD_IP} -P2881 -uroot -proot_password oceanbase -A -c\n```\n\n### OceanBase Dashboard\n\n我们很高兴向用户推出创新的 OceanBase Kubernetes Dashboard，这是一款旨在改善用户在 Kubernetes 上管理和监控 OceanBase 集群体验的先进工具。欢迎各位用户使用和反馈，同时我们也在积极开发新功能以增强未来的更新。[快速上手](https://oceanbase.github.io/ob-operator/zh-Hans/docs/dashboard/quickstart)文档能帮助您快速了解 OceanBase 的功能和使用方法。\n\n安装 OceanBase Dashboard 非常简单, 只需要执行如下命令。\n\n```\nhelm repo add ob-operator https://oceanbase.github.io/ob-operator/\nhelm repo update ob-operator\nhelm install oceanbase-dashboard ob-operator/oceanbase-dashboard\n```\n\n![oceanbase-dashboard-install](./docsite/static/img/oceanbase-dashboard-install.jpg)\n\nOceanBase Dashboard 成功安装之后, 会自动创建一个 admin 用户和随机密码，可以通过如下命令查看密码。\n\n```\necho $(kubectl get -n default secret oceanbase-dashboard-user-credentials -o jsonpath='{.data.admin}' | base64 -d)\n```\n\n一个 NodePort 类型的 service 会默认创建，可以通过如下命令查看 service 的地址，然后在浏览器中打开。\n\n```\nkubectl get svc oceanbase-dashboard-oceanbase-dashboard\n```\n\n![oceanbase-dashboard-service](./docsite/static/img/oceanbase-dashboard-service.jpg)\n\n使用 admin 账号和查看到的密码登录。\n![oceanbase-dashboard-overview](./docsite/static/img/oceanbase-dashboard-overview.jpg)\n![oceanbase-dashboard-topology](./docsite/static/img/oceanbase-dashboard-topology.jpg)\n\n## 项目架构\n\nob-operator 以 kubebuilder 为基础，通过统一的资源管理器接口、全局的任务管理器实例以及解决长调度的任务流机制完成对 OceanBase 集群及相关应用的控制和管理。ob-operator 的架构大致如下图所示：\n\n![ob-operator 架构设计](./docsite/static/img/ob-operator-arch.png)\n\n![ob-operator 任务管理器](./docsite/static/img/ob-operator-task-manager-arch.png)\n\n有关架构细节可参见[架构设计文档](https://oceanbase.github.io/ob-operator/zh-Hans/docs/developer/arch)。\n\n## 特性\n\nob-operator 支持 OceanBase 集群的管理、租户管理、备份恢复、故障恢复等功能，具体而言支持了以下功能：\n\n- [x] 集群管理：集群自举、调整集群拓扑、支持 K8s 拓扑配置、扩缩容、集群升级、修改参数\n- [x] 租户管理：创建租户、调整租户拓扑、管理资源单元、修改用户密码\n- [x] 备份恢复：向 OSS 或 NFS 目的地周期性备份数据、从 OSS 或 NFS 中恢复数据\n- [x] 物理备库：从备份中恢复出备租户、创建空备租户、备租户升主、主备切换\n- [x] 故障恢复：单节点故障恢复，IP 保持情况下的集群故障恢复\n- [x] Dashboard(GUI)：基于 ob-operator 的图形化 OceanBase 集群管理工具\n\n## 存储兼容性\n\n我们测试了如下的存储方案，兼容性结果如表格所示：\n\n| 存储方案               | 测试版本 | 是否兼容 | 说明                               |\n| ---------------------- | -------- | -------- | ---------------------------------- |\n| local-path-provisioner | 0.0.23   | ✅       | 建议开发和测试环境使用             |\n| Rook CephFS            | v1.6.7   | ❌       | CephFS 不支持 `fallocate` 系统调用 |\n| Rook RBD (Block)       | v1.6.7   | ✅       |                                    |\n| OpenEBS (cStor)        | v3.6.0   | ✅       |                                    |\n| GlusterFS              | v1.2.0   | ❓       | 要求机器内核版本不低于 5.14        |\n| Longhorn               | v1.6.0   | ✅       |                                    |\n| JuiceFS                | v1.1.2   | ✅       |                                    |\n| NFS                    | v5.5.0   | ❌       | NFS 协议 \u003e= 4.2 时能启动集群，但无法回收租户资源            |\n\n## 支持的 OceanBase 版本\n\nob-operator 支持 OceanBase v4.x 版本。某些特性需要特定的 OceanBase 版本，可参考用户手册获取详细信息。\n\n暂不支持 OceanBase v3.x 版本。\n\n## 环境依赖\n\nob-operator 使用 [kubebuilder](https://book.kubebuilder.io/introduction) 项目进行构建，所以开发和运行环境与其相近。\n\n- 构建 ob-operator 需要 Go 1.22 版本及以上；\n- 运行 ob-operator 需要 Kubernetes 集群和 kubectl 的版本在 1.18 及以上。我们在 1.23 ~ 1.28 版本的 K8s 集群上检验过 ob-operator 的运行是符合预期的。\n- 如果使用 Docker 作为集群的容器运行时，需要 Docker 17.03 及以上版本；我们的构建和运行环境使用的 Docker 版本为 18。\n\n## 文档\n\n- [架构设计](https://oceanbase.github.io/ob-operator/zh-Hans/docs/developer/arch)\n- [开发手册](https://oceanbase.github.io/ob-operator/docs/developer/contributor-guidance)（英文）\n- [用户手册](https://oceanbase.github.io/ob-operator/zh-Hans/docs/manual/what-is-ob-operator)\n\n## 获取帮助\n\n如果您在使用 ob-operator 时遇到任何问题，欢迎通过以下方式寻求帮助：\n\n- [GitHub Issue](https://github.com/oceanbase/ob-operator/issues)\n- [官方论坛](https://ask.oceanbase.com/)\n- [Slack](https://oceanbase.slack.com/archives/C053PT371S7)\n- 微信群（请添加小助手微信，微信号: OBCE666）\n- [钉钉群](https://h5.dingtalk.com/ecologicalOrg/index.html?code=v1,k1,8FudApZjHxgVTScBrgtz2mBfmEvOuiPm5J5dTS5tos4=\u0026origin=11#/inviteOutsideJoin)\n\n\u003cimg src=\"./docsite/static/img/dingtalk-operator-users.png\" width=\"200px\" alt=\"钉钉群二维码\" /\u003e\n\n## 参与开发\n\n- [提出 Issue](https://github.com/oceanbase/ob-operator/issues)\n- [发起 Discussion](https://github.com/oceanbase/ob-operator/discussions)\n- [发起 Pull request](https://github.com/oceanbase/ob-operator/pulls)\n\n## 许可证\n\nob-operator 使用 [MulanPSL - 2.0](http://license.coscl.org.cn/MulanPSL2) 许可证。\n您可以免费复制及使用源代码。当您修改或分发源代码时，请遵守木兰协议。\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foceanbase%2Fob-operator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foceanbase%2Fob-operator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foceanbase%2Fob-operator/lists"}