This topic describes how to scale out a cluster by adding zones to the cluster.
You can modify the obcluster.yaml configuration file of the OceanBase cluster to add zones.
The spec.topology.cluster[index1].zone attribute in the obcluster.yaml configuration file specifies the distribution of zones in the OceanBase cluster deployed in the cluster[index1] Kubernetes cluster. You can add zones to the OceanBase cluster by modifying the value of this attribute.
Prerequisites
Before you add zones to the OceanBase cluster, make sure that the following prerequisites are met:
The server has sufficient resources for the new zones.
ob-operator determines the distribution of OBServer nodes based on the setting of
nodeSelectorin theobcluster.yamlconfiguration file of OceanBase Database. Therefore, you must first configure labels for Kubernetes nodes. For more information, see Create a cluster.
Procedure
Assume that the current cluster has three zones, zone1, zone2, and zone3, each zone contains one OBServer node, and you want to scale out the cluster to five zones.
Modify the
obcluster.yamlfile to addzone4andzone5.# For example, the OceanBase cluster has three zones. spec: topology: - cluster: cn zone: - name: zone1 region: region1 nodeSelector: ob.zone: zone1 replicas: 1 - name: zone2 region: region1 nodeSelector: ob.zone: zone2 replicas: 1 - name: zone3 region: region1 nodeSelector: ob.zone: zone3 replicas: 1 # Add zone4 and zone5 to the cluster. spec: topology: - cluster: cn zone: - name: zone1 region: region1 nodeSelector: ob.zone: zone1 replicas: 1 - name: zone2 region: region1 nodeSelector: ob.zone: zone2 replicas: 1 - name: zone3 region: region1 nodeSelector: ob.zone: zone3 replicas: 1 - name: zone4 # Newly added zone region: region1 nodeSelector: ob.zone: zone4 replicas: 1 - name: zone5 # Newly added zone region: region1 nodeSelector: ob.zone: zone5 replicas: 1Run the following command for the modification to take effect:
kubectl apply -f obcluster.yamlRun the following command to check whether the modification has taken effect:
kubectl get pods -n obclusterHere is an example of the command output:
NAME READY STATUS RESTARTS AGE sapp-ob-test-cn-zone1-0 2/2 Running 0 8m9s sapp-ob-test-cn-zone2-0 2/2 Running 0 8m9s sapp-ob-test-cn-zone3-0 2/2 Running 0 8m9s sapp-ob-test-cn-zone4-0 2/2 Running 0 8m9s sapp-ob-test-cn-zone5-0 2/2 Running 0 8m9sIf the values of
READYare both2/2and the values ofSTATUSare bothRunningfor the pods corresponding tozone4andzone5,zone4andzone5are added to the cluster.