Horizontal scaling changes the number of pod replicas for a component. KubeBlocks supports scaling the NameServer component. Broker scaling uses the sharding model (see note below).
Before proceeding, verify your environment meets these requirements:
kubectl v1.21+ installed and configured with cluster accessAdd one more NameServer replica:
kubectl apply -f - <<EOF
apiVersion: operations.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: rocketmq-name-server-scale-out
namespace: demo
spec:
clusterName: rocketmq-cluster
type: HorizontalScaling
horizontalScaling:
- componentName: namesrv
scaleOut:
replicaChanges: 1
EOF
Monitor progress:
kubectl get opsrequest rocketmq-name-server-scale-out -n demo -w
NAME TYPE CLUSTER STATUS PROGRESS AGE
rocketmq-name-server-scale-out HorizontalScaling rocketmq-cluster Succeed 1/1 30s
Verify the new replica count:
kubectl get pods -n demo -l app.kubernetes.io/instance=rocketmq-cluster \
-l apps.kubeblocks.io/component-name=namesrv
NAME READY STATUS RESTARTS AGE
rocketmq-cluster-namesrv-0 2/2 Running 0 10m
rocketmq-cluster-namesrv-1 2/2 Running 0 1m
Remove one NameServer replica:
kubectl apply -f - <<EOF
apiVersion: operations.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: rocketmq-name-server-scale-in
namespace: demo
spec:
clusterName: rocketmq-cluster
type: HorizontalScaling
horizontalScaling:
- componentName: namesrv
scaleIn:
replicaChanges: 1
EOF
Monitor progress:
kubectl get opsrequest rocketmq-name-server-scale-in -n demo -w
NAME TYPE CLUSTER STATUS PROGRESS AGE
rocketmq-name-server-scale-in HorizontalScaling rocketmq-cluster Succeed 1/1 25s
Broker shards cannot be scaled via HorizontalScaling OpsRequest. To add more broker capacity, change shards in the Cluster spec directly. Increasing replicas within a shard (master + slave) must also be done via the Cluster spec, not OpsRequest.
kubectl delete opsrequest rocketmq-name-server-scale-out rocketmq-name-server-scale-in -n demo --ignore-not-found