The ob-operator is a Kubernetes operator that simplifies the deployment and management of OceanBase cluster and related resources on Kubernetes.
此文档也提供中文版。
This section provides a step-by-step guide on how to use ob-operator to deploy an OceanBase cluster.
Before getting started, please ensure you have a functional Kubernetes cluster with at least 2 CPU cores, 10GB of memory, and 100GB of storage space available.
ob-operator relies on cert-manager for certificate management. For instructions on installing cert-manager, please refer to the corresponding installation documentation.
If you have trouble accessing quay.io
image registry, our mirrored cert-manager manifests can be applied through following command:
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.1_release/deploy/cert-manager.yaml
Storage of OceanBase cluster in this example relies on local-path-provisioner, which should be installed beforehand. You should confirm that there is enough disk space in storage destination of local-path-provisioner.
You can deploy ob-operator in a Kubernetes cluster by executing the following command:
- Stable
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.1_release/deploy/operator.yaml
- Development
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/master/deploy/operator.yaml
Helm Chart parameterizes the namespace in which ob-operator is deployed, allowing you to specify the namespace before installing ob-operator.
helm repo add ob-operator https://oceanbase.github.io/ob-operator/
helm install ob-operator ob-operator/ob-operator --namespace=oceanbase-system --create-namespace --version=2.1.1
After deployment/installation is complete, you can use the following command to verify if ob-operator is deployed successfully:
kubectl get pod -n oceanbase-system
# desired output
NAME READY STATUS RESTARTS AGE
oceanbase-controller-manager-86cfc8f7bf-4hfnj 2/2 Running 0 1m
Before creating an OceanBase cluster, you need to create several secrets to store specific users' passwords for OceanBase.
kubectl create secret generic root-password --from-literal=password='root_password'
kubectl create secret generic proxyro-password --from-literal=password='proxyro_password'
kubectl create secret generic monitor-password --from-literal=password='monitor_password'
kubectl create secret generic operator-password --from-literal=password='operator_password'
You can deploy OceanBase in a Kubernetes cluster by executing the following command:
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.1_release/example/quickstart/obcluster.yaml
It generally takes around 2 minutes to bootstrap a cluster. Execute the following command to check the status of the cluster. Once the cluster status changes to "running," it indicates that the cluster has been successfully created and bootstrapped:
kubectl get obclusters.oceanbase.oceanbase.com test
# desired output
NAME STATUS AGE
test running 6m2s
Use the following command to find the POD IP of the observer. The naming convention for PODs is {cluster_name}-{cluster_id}-{zone}-uuid:
kubectl get pods -o wide
To connect, use the following command:
mysql -h{POD_IP} -P2881 -uroot -proot_password oceanbase -A -c
ob-operator is built on top of kubebuilder and provides control and management of OceanBase clusters and related applications through a unified resource manager interface, a global task manager instance, and a task flow mechanism for handling long-running tasks. The architecture diagram is approximately as follows:
For more detailed information about the architecture, please refer to the Architecture Document.
It provides various functionalities for managing OceanBase clusters, tenants, backup and recovery, and fault recovery. Specifically, ob-operator supports the following features:
- Cluster Management: Bootstrap the cluster, adjust cluster topology, support K8s topology configuration, scale-in/out, cluster upgrade, modify parameters.
- Tenant Management: Create tenants, adjust tenant topology, manage resource units, modify user passwords.
- Backup and Recovery: Periodically backup data to OSS or NFS destinations, restore data from OSS or NFS.
- Physical Standby: Restore standby tenant from backup, create empty standby tenant, activate standby tenant to primary, primary-standby switchover.
- Fault Recovery: Single node fault recovery, cluster-wide fault recovery with IP preservation.
The upcoming features include:
- Dashboard: A web-based graphical management tool for OceanBase clusters based on ob-operator.
- Enhanced operational task resources: This includes lightweight tasks focused on cluster and tenant management, among other features.
ob-operator supports OceanBase v4.x versions. The validated versions include 4.1.x and 4.2.x. It will continue to support new versions of the OceanBase community edition.
OceanBase v3.x versions are currently not supported by ob-operator.
ob-operator is built using the kubebuilder project, so the development and runtime environment are similar to it.
- To build ob-operator: Go version 1.20 or higher is required.
- To run ob-operator: Kubernetes cluster and kubectl version 1.18 or higher are required. We examined the functionalities on k8s cluster of version from 1.23 ~ 1.25 and ob-operator performs well.
- If using Docker as the container runtime for the cluster, Docker version 17.03 or higher is required. We tested building and running ob-operator with Docker 18.
If you encounter any issues while using ob-operator, please feel free to seek help through the following channels:
- GitHub Issue
- Official Website
- Slack
- DingTalk Group (QRCode)
- WeChat Group (Add the assistant with WeChat ID: OBCE666)
ob-operator is licensed under the MulanPSL - 2.0 License. You are free to copy and use the source code. When you modify or distribute the source code, please comply with the MulanPSL - 2.0 Agreement.