This topic describes how to scale in a cluster by deleting zones from the cluster.
Note
Before you delete a zone from a cluster, make sure that the zone contains no replicas of tenants.
You can modify the obcluster.yaml configuration file of the OceanBase cluster to delete zones from the cluster.
The spec.topology.cluster[index1].zone attribute in the obcluster.yaml configuration file specifies the distribution of zones of the OceanBase cluster deployed in the [index1] Kubernetes cluster. You can modify the value of this attribute to delete zones from the cluster.
Procedure
Assume that the current cluster has five zones, zone1, zone2, zone3, zone4, and zone5, each zone contains one OBServer node, and you want to reduce the number of zones of the cluster to three.
Modify the
obcluster.yamlconfiguration file to deletezone4andzone5.# For example, the OceanBase cluster has five 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 - name: zone4 region: region1 nodeSelector: ob.zone: zone3 replicas: 1 - name: zone5 region: region1 nodeSelector: ob.zone: zone3 replicas: 1 # Delete zone4 and zone5 from 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: 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 8m9sThe preceding result shows that the cluster has only three zones,
zone1,zone2, andzone3.zone4andzone5have been deleted.