This topic describes how to deploy OceanBase Database in a Kubernetes environment by using ob-operator.
Prerequisites
Before getting started, ensure that you meet the following requirements:
- You have an available Kubernetes cluster with at least 2 CPUs, 10 GB of memory, and 100 GB of storage space.
- You have installed cert-manager. For more information about the installation method, see Installation.
- You have installed local-path-provisioner and the configured target location has sufficient storage space. For more information about the installation method, see Installation.
Deploy ob-operator
Run the following command to deploy ob-operator in the Kubernetes cluster:
Stable version
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.0_release/deploy/operator.yamlDevelopment version
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/master/deploy/operator.yaml
Run the following command to check whether ob-operator is successfully deployed:
kubectl get pod -n oceanbase-system
The expected output is as follows:
NAME READY STATUS RESTARTS AGE
oceanbase-controller-manager-86cfc8f7bf-4hfnj 2/2 Running 0 1m
Deploy the OceanBase cluster
Follow the steps below to deploy and connect to the OceanBase cluster in the Kubernetes cluster:
Create secrets.
Before creating an OceanBase cluster, you must create the secrets required for specific users. The command for creating secrets is as follows:
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'Deploy the OceanBase cluster.
Use the following command to deploy the OceanBase cluster in the Kubernetes cluster:
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.0_release/example/quickstart/obcluster.yamlThe creation process usually takes about 2 minutes. Use the following command to check the cluster status:
kubectl get obclusters.oceanbase.oceanbase.com testThe expected output is as follows:
NAME STATUS AGE test running 6m2sConnect to the OceanBase cluster.
Follow the steps below to connect to the newly created OceanBase cluster:
# Use the following command to find the observer's POD IP and POD name. # The name of the POD follows the format {cluster_name}-{cluster_id}-{zone}-uuid. kubectl get pods -o wide # Use the following command to connect to the cluster: mysql -h{POD_IP} -P2881 -uroot -p'root_password' oceanbase -A -c
Reference
If you need more details on how to deploy and manage OceanBase Database in a Kubernetes environment using ob-operator, you can refer to the following documents or code repository.