OceanBase
English日本語简体中文
Docs Home
Products
Integrations
Release Notes

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service
OceanBase DatabaseOceanBase Cloud ToolsConnectors and MiddlewareLifecycle Support Policy

Kubernetes operator for OceanBase

V2.1.2Community Edition
  • Overview
  • Quick start
  • Deploy
  • Upgrade
  • Configure
  • User guide
    • Cluster management
      • Manage clusters
      • Create a cluster
      • Zone management
        • Add zones to a cluster
        • Delete zones from a cluster
      • Server management
        • Add OBServer nodes to zones
        • Delete OBServer nodes from zones
      • Upgrade a cluster
      • Manage parameters
      • Delete a cluster
    • Tenant management
      • Manage tenants
      • Create a tenant
      • Modify tenant
        • Manage resources
        • Manage replicas
        • Modify other parameters
      • Delete a tenant
      • Perform tenant O&M operations
    • High availability
      • High availability
      • Restore service from node failure
      • Back up a tenant
      • Restore data from a backup
      • Physical standby tenant
  • Appendix
    • Deploy OceanBase Database and applications in a Kubernetes cluster
    • FAQ
  • Changelog

Download PDF

Document Feedback
  1. Documentation Center
  2. Kubernetes operator for OceanBase
  3. V2.1.2

Deploy OceanBase Database and applications in a Kubernetes cluster

Last Updated:2026-09-04 08:21:43

Prerequisites
Deploy OceanBase Database and related components
Preparations before deployment
Deploy ob-configserver
Deploy an OceanBase cluster
Deploy ODP
Deploy applications
Create a tenant
Deploy an application
Deploy the monitoring system
Deploy Prometheus
Deploy Grafana
Summary
Note

This topic describes how to deploy OceanBase Database, related components, and applications in a Kubernetes cluster by using a real-world example.

Prerequisites

Before you start the deployment, make sure that you have deployed cert-manager, local-path-provisioner, and ob-operator in your Kubernetes cluster.

In this example, the following components are deployed:

  • OceanBase Database.
  • ob-configserver, which is used to register the IP address of the RootService server for OceanBase Database.
  • OceanBase Database Proxy (ODP), the proxy of OceanBase Database.
  • OceanBase Cloud Platform (OCP). OCP is taken as an example to describe how to deploy web applications in the Kubernetes cluster.
  • Prometheus, the monitoring and alerting system that collects and calculates the monitoring metrics of OceanBase Database.
  • Grafana, the data visualization system. You can connect Grafana to Prometheus to display the monitoring data of OceanBase Database.

Deploy OceanBase Database and related components

Preparations before deployment

Create a namespace:

kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.0_release/example/webapp/namespace.yaml

View the created namespace:

kubectl get namespace oceanbase

The following output indicates that the namespace is created:

NAME        STATUS   AGE
oceanbase   Active   98s

Create secrets for the cluster and tenants:

kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.0_release/example/webapp/secret.yaml

View the created secrets:

kubectl get secret -n oceanbase

The following output indicates that the secrets are created:

NAME                      TYPE                                  DATA   AGE
sc-metatenant-root        Opaque                                1      11s
sc-metatenant-standbyro   Opaque                                1      11s
sc-sys-monitor            Opaque                                1      11s
sc-sys-operator           Opaque                                1      11s
sc-sys-proxyro            Opaque                                1      11s
sc-sys-root               Opaque                                1      11s

Deploy ob-configserver

ob-configserver allows you to register, store, and query metadata of the RootService server for OceanBase Database. The supported metadata storage types are sqlite3 and mysql. In this example, sqlite3 is used. Run the following command to deploy ob-configserver and create the corresponding service:

kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.0_release/example/webapp/configserver.yaml

Check the pod status:

kubectl get pods -n oceanbase | grep ob-configserver

# desired output
ob-configserver-856bf5d865-dlwxr   1/1     Running   0          16s

Check the svc status:

kubectl get svc svc-ob-configserver -n oceanbase

# desired output
NAME                  TYPE       CLUSTER-IP   EXTERNAL-IP   PORT(S)          AGE
svc-ob-configserver   NodePort   10.96.3.39   <none>        8080:30080/TCP   98s

Deploy an OceanBase cluster

When you deploy an OceanBase cluster, add environment variables and set the system parameter obconfig_url to the IP address of ob-configserver service. OceanBase Database will register the information of RootService with ob-configserver. Deploy the OceanBase cluster:

kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.0_release/example/webapp/obcluster.yaml

Run the following command to query the status of the OceanBase cluster until the status becomes running:

kubectl get obclusters.oceanbase.oceanbase.com metadb -n oceanbase

# desired output
NAME     STATUS    AGE
metadb   running   3m21s

Deploy ODP

You can start ODP by using ob-configserver or specifying the RS list. To maximize the performance of ODP, we recommend that you connect ODP to the cluster by using ob-configserver.

Run the following command to deploy ODP and create the ODP service:

kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.0_release/example/webapp/obproxy.yaml

When you query the pod status of ODP, you can see two ODP pods.

kubectl get pod -A | grep obproxy

# desired output
oceanbase            obproxy-5cb8f4d975-pmr59                          1/1     Running   0          21s
oceanbase            obproxy-5cb8f4d975-xlvjp                          1/1     Running   0          21s

View information about the ODP service:

kubectl get svc svc-obproxy -n oceanbase

# desired output
NAME          TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)             AGE
svc-obproxy   ClusterIP   10.96.2.46   <none>        2883/TCP,2884/TCP   2m26s

Connect to the OceanBase cluster by using the IP address of the ODP service:

mysql -h${obproxy-service-address} -P2883 -uroot@sys#metadb -p

If the OceanBase cluster is connected, the ODP service is normal.

connection

If the cluster not exist message is returned, it indicates that the OceanBase cluster has not registered the cluster metadata with ob-configserver. Try again later. You can view the registration result by using the curl "http://127.0.0.1:30080/services?Action=ObRootServiceInfo&ObCluster=metadb" statement. If the RsList parameter is not empty in the response, the cluster metadata is registered.

Deploy applications

Create a tenant

You can create a dedicated tenant for each type of business for better resource isolation. In this example, one tenant is created.

Run the following command to create a tenant:

kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.0_release/example/webapp/tenant.yaml

Run the following command to query the status of the tenant until the status becomes running:

kubectl get obtenants.oceanbase.oceanbase.com metatenant -n oceanbase
NAME         STATUS    TENANTNAME   TENANTROLE   CLUSTERNAME   AGE
metatenant   running   metatenant   PRIMARY      metadb        106s

Run the following command to verify that the tenant can be connected:

mysql -h${obproxy-service-address} -P2883 -uroot@metatenant#metadb -p

If the tenant is connected, you can use it.

Deploy an application

OCP is taken as an example to describe how to deploy a web application. Create databases Run the following command to create databases:

# connect tenant
mysql -h${obproxy-service-address} -P2883 -uroot@metatenant#metadb -p

# create meta database
create database ocp_metadb;

# create monitor database
create database ocp_monitordb;

Run the following command to deploy the application:

kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.0_release/example/webapp/ocp.yaml

After the deployment process is completed, run the following command to view the application status:

# check pod
kubectl get pods -n oceanbase | grep ocp
ocp-6bb784f89f-q6cbs               1/1     Running   0          12m

# check service
kubectl get svc svc-ocp -n oceanbase
NAME      TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
svc-ocp   NodePort   10.43.39.231   <none>        8080:32080/TCP   12m

An application provides service a while after it is deployed. You can access the application by using the service address.

# check by query time api
curl -L 'http://${service_ip}:${server_port}/api/v2/time'
"2023-11-27T00:00:13.687+08:00"

Deploy the monitoring system

Deploy Prometheus

When you deploy the OceanBase cluster, an OBAgent sidecar container is created in each pod to provide monitoring data over the Prometheus protocol. A service is also created to automatically identify the IP address of OBAgent to collect data with the service discovery feature enabled.

Run the following command to deploy Prometheus:

kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.0_release/example/webapp/prometheus.yaml

Run the following command to view the deployment status:

# check pod status
kubectl get pods -n oceanbase | grep prometheus
prometheus-576d7757b9-jsvfh        1/1     Running   0          3m17s

# check service status
kubectl get svc svc-prometheus -n oceanbase
NAME             TYPE       CLUSTER-IP    EXTERNAL-IP   PORT(S)          AGE
svc-prometheus   NodePort   10.96.1.212   <none>        9090:30090/TCP   3m45s

Deploy Grafana

Grafana displays the metrics of OceanBase Database by using Prometheus as a data source. Run the following command to deploy Grafana:

kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.0_release/example/webapp/grafana.yaml

Run the following command to view the deployment status:

# check pod status
kubectl get pods -n oceanbase | grep grafana
grafana-b7c6c6ccb-dkv57            1/1     Running   0          2m

# check service status
kubectl get svc svc-grafana -n oceanbase
NAME          TYPE       CLUSTER-IP    EXTERNAL-IP   PORT(S)          AGE
svc-grafana   NodePort   10.96.2.145   <none>        3000:30030/TCP   2m

Open a browser and visit the service address to view the monitoring metrics of OceanBase Database.

Grafana

Summary

This topic describes how to deploy OceanBase Database and related components such as ODP and ob-configserver, applications, and the monitoring system. You can deploy other applications based on the example.

Note

You can find all configuration files used in this topic in the webapp directory.

Previous topic

Physical standby tenant
Last

Next topic

FAQ
Next
on this page
Prerequisites
Deploy OceanBase Database and related components
Preparations before deployment
Deploy ob-configserver
Deploy an OceanBase cluster
Deploy ODP
Deploy applications
Create a tenant
Deploy an application
Deploy the monitoring system
Deploy Prometheus
Deploy Grafana
Summary
Note