OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

Kubernetes operator for OceanBase

V2.3.1Community Edition

  • Overview
  • Quick start
  • Deploy
  • Upgrade
  • 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
      • Update resources
      • 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
      • Recover from node failure
      • Back up a tenant
      • Restore data from a backup
      • Physical standby tenant
      • Inter K8s cluster management
  • Configure
  • Appendix
    • Deploy OceanBase Database and web app in a Kubernetes cluster
    • FAQ
  • Changelog

Download PDF

Overview Quick start Deploy Upgrade Manage clusters Create a cluster Upgrade a cluster Manage parameters Update resources Delete a cluster Manage tenants Create a tenant Delete a tenant Perform tenant O&M operations High availability Recover from node failure Back up a tenant Restore data from a backup Physical standby tenant Inter K8s cluster management Configure Deploy OceanBase Database and web app in a Kubernetes cluster FAQ Changelog
OceanBase logo

The Unified Distributed Database for the AI Era.

Follow Us
Products
OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
Resources
DocsBlogLive DemosTraining & Certification
Company
About OceanBaseTrust CenterLegalPartnerContact Us
Follow Us

© OceanBase 2026. All rights reserved

Cloud Service AgreementPrivacy PolicySecurity
Contact Us
Document Feedback
  1. Documentation Center
  2. Kubernetes operator for OceanBase
  3. V2.3.1
iconKubernetes operator for OceanBase
V 2.3.1Community Edition
Community Edition
  • V 2.3.1
  • V 2.3.0
  • V 2.2.0
  • V 2.1.2
  • V 2.1.1
  • V 2.1.0

Create a cluster

Last Updated:2025-11-28 06:07:04  Updated
share
What is on this page
Preparations before deployment
Deploy OceanBase Database
Create a namespace
Create secrets for default users
Define the OceanBase cluster
Create a cluster
Connect to the cluster
What to do next

folded

share

This topic describes how to create an OceanBase cluster by using ob-operator.

Preparations before deployment

You must have deployed ob-operator in a Kubernetes cluster. For more information, see Deploy ob-operator. Make sure that the Kubernetes cluster has an available storage class. We recommend that you use local-path-provisioner.

Deploy OceanBase Database

Create a namespace

Run the following command to create a namespace for deploying an OceanBase cluster.

kubectl create namespace oceanbase

Create secrets for default users

Run the following command to create secrets for specific users of the cluster.

kubectl create secret -n oceanbase generic root-password --from-literal=password='root_password'

Define the OceanBase cluster

You can use the YAML configuration file to define the OceanBase cluster. Here is an example:

apiVersion: oceanbase.oceanbase.com/v1alpha1
kind: OBCluster
metadata:
  name: test
  namespace: oceanbase
  annotations:
    "oceanbase.oceanbase.com/independent-pvc-lifecycle": "true" 
    # "oceanbase.oceanbase.com/mode": "standalone" or "service"
    # "oceanbase.oceanbase.com/single-pvc": "true" 
spec:
  clusterName: obcluster
  clusterId: 1
  serviceAccount: "default"
  userSecrets:
    root: root-password
  topology:
    - zone: zone1
      replica: 1
      # nodeSelector:
      #   k1: v1
      # affinity:
      #   nodeAffinity:
      #   podAffinity:
      #   podAntiAffinity:
      # tolerations:
      #   - key: "obtopo"
      #     value: "zone"
      #     effect: "NoSchedule"
    - zone: zone2
      replica: 1
    - zone: zone3
      replica: 1
  observer:
    image: oceanbase/oceanbase-cloud-native:4.2.0.0-101000032023091319
    resource:
      cpu: 2
      memory: 10Gi
    storage:
      dataStorage:
        storageClass: local-path
        size: 50Gi
      redoLogStorage:
        storageClass: local-path
        size: 50Gi
      logStorage:
        storageClass: local-path
        size: 20Gi
  monitor:
    image: oceanbase/obagent:4.2.0-100000062023080210
    resource:
      cpu: 1
      memory: 1Gi

  # parameters:
  #   - name: system_memory
  #     value: 2G
  # backupVolume:
  #   volume:
  #     name: backup
  #     nfs:
  #       server: 1.1.1.1
  #       path: /opt/nfs
  #       readOnly: false

Parameters

The following table describes the parameters.

Parameter Description
metadata.name Required. The name of the cluster, which is the name of resources in the Kubernetes cluster.
metadata.namespace Required. The namespace where the cluster resides.
spec.clusterName Required. The name of the OceanBase cluster.
spec.clusterId Required. The ID of the OceanBase cluster.
spec.serviceAccount Optional. The service account that will be bound to OBServer pods.
spec.userSecrets Required. The secrets of default users of the OceanBase cluster.
spec.userSecrets.root Required. The secret of the root@sys user in the OceanBase cluster. The secret must contain the password keyword.
spec.userSecrets.proxyro Optional. The secret of the proxyro@sys user in the OceanBase cluster. The secret must contain the password keyword.
spec.userSecrets.monitor Optional. The secret of the monitor@sys user in the OceanBase cluster. The secret must contain the password keyword.
spec.userSecrets.operator Optional. The secret of the operator@sys user in the OceanBase cluster. The secret must contain the password keyword.
spec.topology Required. The definition of the topology of the OceanBase cluster, which contains the definition of each zone.
spec.topology[i].zone Required. The name of the zone in the OceanBase cluster.
spec.topology[i].replica Required. The number of OBServer nodes in the zone.
spec.topology[i].nodeSelector Optional. Specifies the distribution of pods across the OBServer nodes in the zone. The value is in the mapping format. This parameter must be used with the labels of OBServer nodes.
spec.topology[i].affinity Specifies the affinity among the OBServer nodes in the zone. For more information, visit kubernetes.io.
spec.topology[i].tolerations Specifies the toleration of OBServer nodes in the zone. For more information, visit kubernetes.io.
spec.observer.image Required. The OBServer image of the OceanBase cluster.
spec.observer.resource Required. The resource specifications of OBServer nodes.
spec.observer.resource.cpu Required. The number of CPU cores for OBServer nodes.
spec.observer.resource.memory Required. The memory size for OBServer nodes.
spec.observer.storage Required. The storage size for OBServer nodes.
spec.observer.storage.dataStorage Required. The data storage size for OBServer nodes.
spec.observer.storage.redoLogStorage Required. The clog storage size for OBServer nodes.
spec.observer.storage.logStorage Required. The runtime log storage size for OBServer nodes.
spec.observer.storage.*.storageClass Optional. The storage class required for creating a PersistentVolumeClaim (PVC). Set to default storageClass in kubernetes cluster if leaving it empty. This parameter takes effect on storage configurations.
spec.observer.storage.*.size Required. The size of the created PVC. This parameter takes effect on storage configurations.
spec.monitor Optional. The monitoring configuration. We recommend that you enable this parameter. ob-operator uses obagent to collect monitoring data. You can connect ob-operator to Prometheus to monitor the status of the OceanBase cluster.
spec.monitor.image Required. The image used for monitoring.
spec.monitor.resource Required. The resources allocated to the monitoring container.
spec.monitor.resource.cpu Required. The number of CPU cores allocated to the monitoring container.
spec.monitor.resource.memory Required. The memory size allocated to the monitoring container.
spec.parameters The optional custom parameter of the OceanBase cluster. This parameter takes effect globally in the cluster.
spec.parameters[i].name Required. The name of the parameter.
spec.parameters[i].value Required. The value of the parameter.
spec.backupVolume Optional. The backup storage for the OceanBase cluster. If you want to enable the backup feature and do not use Alibaba Cloud Object Storage Service (OSS) for backup storage, you need to specify this parameter. You can configure a Network File System (NFS) volume.

Annotations

The following table describes available annotations. For short, the annotation annotation implies there is an oceanbase.oceanbase.com/ in front of it.

Annotation Description
independent-pvc-lifecycle true: Require ob-operator >= 2.1.1. PVCs won't be deleted even if the OBCluster is deleted.
mode standalone: Require ob-operator >= 2.1.1 and observer version >= 4.2.0. Bootstrap the single-node cluster with 127.0.0.1, which cannot contact other nodes any more.
service: Require ob-operator >= 2.2.0 and observer version >= 4.2.1.4 excepting 4.2.2.x. Create a specific K8s service for each OBServer and use the service's ClusterIP as the OBServer's IP address.
single-pvc true: Require ob-operator >= 2.1.2. Create and bind a single PVC to a OBServer pod (three PVCs by default).

Create a cluster

After you save the configuration file, run the following command to create an OceanBase cluster in the Kubernetes cluster:

kubectl apply -f obcluster.yaml

In general, it takes about 2 minutes to create a cluster. Run the following command to query the cluster status. If the cluster status changes to Running, the cluster is created.

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

# desired output
NAME   STATUS    AGE
test   running   6m2s

Connect to the cluster

Run the following command to obtain the IP address of the pod for the server where the cluster is deployed. The pod name is in the {cluster_name}-{cluster_id}-{zone}-uuid format.

kubectl get pods -n oceanbase -o wide

Run the following command to connect to the pod:

mysql -h{POD_IP} -P2881 -uroot -proot_password oceanbase -A -c

What to do next

After the cluster is created, you must create a tenant for your business. For more information, see Manage tenants.

Previous topic

Manage clusters
Last

Next topic

Add zones to a cluster
Next
What is on this page
Preparations before deployment
Deploy OceanBase Database
Create a namespace
Create secrets for default users
Define the OceanBase cluster
Create a cluster
Connect to the cluster
What to do next