How to Deploy OceanBase with OB-Operator on Kubernetes: Step‑by‑Step Guide
This guide walks you through installing the OB‑Operator, preparing Kubernetes prerequisites, deploying the operator and an OceanBase cluster, and verifying the deployment, providing practical commands and configuration examples for a production‑ready setup.
1. OB‑Operator Overview
ob-operator is a Kubernetes Operator‑based automation tool that greatly simplifies deploying and managing OceanBase clusters and related resources on Kubernetes.
It supports cluster management, tenant management, backup & restore, physical standby, fault recovery, and provides a GUI dashboard.
Cluster management: bootstrap, topology adjustments, K8s topology config, scaling, upgrades, parameter changes.
Tenant management: create tenants, adjust topology, manage resource units, change passwords.
Backup & restore: periodic backups to OSS or NFS, restore from those locations.
Physical standby: create standby tenants, promote, failover.
Fault recovery: single‑node recovery with IP preservation.
Dashboard (GUI): graphical management tool built on OB‑Operator.
2. Prerequisites for Deploying OceanBase
Before starting, ensure the following:
Kubernetes version > 1.18.
OceanBase version 4.2.5 or 4.3.3, depending on requirements.
Kubernetes resources managed by local-path-provisioner with local PVs on nodes.
cert‑manager installed (OB‑Operator depends on it).
<code>kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.16.1/cert-manager.yaml
namespace/cert-manager created
customresourcedefinition.apiextensions.k8s.io/certificaterequests.cert-manager.io created
... (additional resources created) ...
service/cert-manager-webhook created
deployment.apps/cert-manager-webhook created
mutatingwebhookconfiguration.admissionregistration.k8s.io/cert-manager-webhook created
validatingwebhookconfiguration.admissionregistration.k8s.io/cert-manager-webhook created</code>3. Deploy OB‑Operator
Install the latest OB‑Operator (example uses version 2.2.0; 2.3.0 is recommended):
<code>/opt/ob-operator# helm repo add ob-operator https://oceanbase.github.io/ob-operator/
"ob-operator" has been added to your repositories
/opt/ob-operator# helm install ob-operator ob-operator/ob-operator \
--namespace=oceanbase-system --create-namespace --version=2.2.0
NAME: ob-operator
LAST DEPLOYED: Mon Oct 28 10:53:12 2024
NAMESPACE: oceanbase-system
STATUS: deployed
REVISION: 1
TEST SUITE: None</code>The deployment requires the operator image to be available in your private registry; otherwise you may encounter image‑pull failures:
<code>Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning Failed 31m kubelet Failed to pull image "oceanbase/ob-operator:2.2.0": rpc error: code = Unknown desc = Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp 199.16.158.190:443: connect: connection timed out
Normal Pulling 26m kubelet Pulling image "oceanbase/ob-operator:2.2.0"
Normal BackOff 91s kubelet Back-off pulling image "oceanbase/ob-operator:2.2.0"</code>Verify the operator pods:
<code>/opt/ob-operator# kubectl get pods -n oceanbase-system
NAME READY STATUS RESTARTS AGE
oceanbase-controller-manager-85f4b9d58c-cl9rq 2/2 Running 0 3m27s</code>4. Deploy OceanBase Cluster
Follow these steps on the Kubernetes cluster:
Create a namespace: kubectl create ns oceanbase-test
Create required secrets (replace yourpassword with a secure password):
<code>kubectl create secret generic ob-root-password --from-literal=password='yourpassword' -n oceanbase-test
kubectl create secret generic ob-proxyro-password --from-literal=password='yourpassword' -n oceanbase-test</code>Note: avoid special characters in ob-proxyro-password to prevent connection issues.
Edit the OBCluster YAML (example file oceanbase-test.yaml ):
<code>apiVersion: oceanbase.oceanbase.com/v1alpha1
kind: OBCluster
metadata:
name: obcluster-test # OBCluster name
namespace: oceanbase-test
spec:
clusterName: obcluster-test
clusterId: 1
userSecrets:
root: ob-root-password
proxyro: ob-proxyro-password
topology:
- zone: zone1
replica: 1
- zone: zone2
replica: 1
- zone: zone3
replica: 1
observer:
image: oceanbase/oceanbase-cloud-native:4.3.3.0-100000142024101215
resource:
cpu: 12
memory: 40Gi
storage:
dataStorage:
storageClass: local-ssd-storage
size: 500Gi
redoLogStorage:
storageClass: local-ssd-storage
size: 150Gi
logStorage:
storageClass: local-ssd-storage
size: 20Gi
monitor:
image: oceanbase/obagent:4.2.1-100000092023101717
resource:
cpu: 8
memory: 10Gi</code>Apply the YAML and wait about two minutes for the cluster to be created:
<code>kubectl apply -f oceanbase-test.yaml -n oceanbase-test</code>Make sure the required images are pulled into your private registry:
<code>oceanbase/oceanbase-cloud-native:4.3.3.0-100000142024101215
oceanbase/obagent:4.2.1-100000092023101717</code>Check the OBCluster status and pods:
<code>/opt/ob-operator# kubectl get obcluster -n oceanbase-test1
NAME STATUS AGE
obcluster running 3d2h
/opt/ob-operator# kubectl get pods -n oceanbase-test1 -o wide
NAME READY STATUS RESTARTS AGE IP NODE ...
obcluster-test-1-zone1-6a036c0d84bf 2/2 Running 0 3d2h 10.xxx.xxx.143 db02 ...
obcluster-test-1-zone2-384f9bf55992 2/2 Running 0 3d2h 10.xxx.xxx.142 db08 ...
obcluster-test-1-zone3-6f375db39867 2/2 Running 0 3d2h 10.xxx.xxx.242 db07 ...
obproxy-test-6479ccb497-6r7xv 1/1 Running 0 2d6h 10.xxx.xxx.182 kube60 ...
obproxy-test-6479ccb497-bnj48 1/1 Running 0 2d6h 10.xxx.xxx.227 kube60 ...</code>Since no OBProxy is deployed, access the cluster directly via the OB pod IP:
<code>/opt/ob-operator# mysql -h10.xxx.xxx.143 -P2881 -uroot@sys -p oceanbase -A -c
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3221489701
Server version: 5.7.25 OceanBase_CE 4.3.3.0-...
show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| LBACSYS |
| mysql |
| oceanbase |
| ORAAUDITOR |
| SYS |
| sys_external_tbs |
| test |
+--------------------+
8 rows in set (0.01 sec)
mysql> exit
Bye</code>5. Summary
OB‑Operator, built on the Kubernetes Operator framework, provides declarative management, automated tuning, and unified control for OceanBase clusters, offering a simple and reliable way to containerize and operate OceanBase in production environments.
For deeper information, refer to the official documentation and GitHub repository.
Xiaolei Talks DB
Sharing daily database operations insights, from distributed databases to cloud migration. Author: Dai Xiaolei, with 10+ years of DB ops and development experience. Your support is appreciated.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.