You are looking at the documentation of a prior release. To read the documentation of the latest release, please
visit here.
New to KubeDB? Please start here.
Horizontal Scale MaxScale
This guide will show you how to use KubeDB Ops-manager operator to scale MaxScale server.
Before You Begin
At first, you need to have a Kubernetes cluster, and the
kubectlcommand-line tool must be configured to communicate with your cluster. If you do not already have a cluster, you can create one by using kind.Install
KubeDBoperator in your cluster following the steps here.You should be familiar with the following
KubeDBconcepts:
To keep everything isolated, we are going to use a separate namespace called demo throughout this tutorial.
$ kubectl create ns demo
namespace/demo created
Apply Horizontal Scaling on MaxScale Server
Here, we are going to deploy a MariaDB cluster in replication mode using a supported version by KubeDB operator. Then we are going to apply horizontal scaling on MaxScale server.
Deploy MariaDB Cluster
In this section, we are going to deploy a MariaDB cluster in replication mode. Below is the YAML of the MariaDB CR that we are going to create,
apiVersion: kubedb.com/v1
kind: MariaDB
metadata:
name: md-replication
namespace: demo
spec:
version: "10.5.23"
replicas: 3
topology:
mode: MariaDBReplication
maxscale:
replicas: 3
enableUI: true
storageType: Durable
storage:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Mi
storageType: Durable
storage:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
deletionPolicy: WipeOut
Let’s create the MariaDB CR we have shown above,
$ kubectl create -f https://github.com/kubedb/docs/raw/v2025.8.31/docs/examples/mariadb/scaling/md-replication.yaml
mariadb.kubedb.com/md-replication created
Now, wait until md-replication has status Ready. i.e,
$ kubectl get mariadb -n demo
NAME VERSION STATUS AGE
md-replication 10.5.23 Ready 2m8s
Let’s check the number of replicas Maxscale has from the MariaDB object, also the number of replicas the petset have,
$ kubectl get mariadb -n demo md-replication -o json | jq '.spec.topology.maxscale.replicas'
3
$ kubectl get petset -n demo md-replication-mx -o json | jq '.spec.replicas'
3
We can see from both command that the MaxScale has 3 replicas in the cluster.
Scale Up Replicas
Here, we are going to scale up the replicas of the replicaset to meet the desired number of replicas after scaling.
Create MariaDBOpsRequest
In order to scale up the replicas of the replicaset of the MaxScale server, we have to create a MariaDBOpsRequest CR with our desired replicas. Below is the YAML of the MariaDBOpsRequest CR that we are going to create,
apiVersion: ops.kubedb.com/v1alpha1
kind: MariaDBOpsRequest
metadata:
name: maxscale-horizontal-scale-up
namespace: demo
spec:
type: HorizontalScaling
databaseRef:
name: md-replication
horizontalScaling:
maxscale: true
member: 4
Here,
spec.typespecifies that we are performingHorizontalScalingon our database.spec.databaseRef.namespecifies that we are performing horizontal scaling operation onmd-replicationdatabase.spec.horizontalScaling.maxscalespecifies that we are performing horizontal scaling operation on maxscale server. If false then horizontal scaling performs on mariadb database.spec.horizontalScaling.memberspecifies the desired replicas after scaling.
Let’s create the MariaDBOpsRequest CR we have shown above,
$ kubectl apply -f https://github.com/kubedb/docs/raw/v2025.8.31/docs/examples/mariadb/scaling/horizontal-scaling/mx-hscale-up.yaml
mariadbopsrequest.ops.kubedb.com/maxscale-horizontal-scale-up created
Verify Cluster replicas scaled up successfully
If everything goes well, KubeDB Ops-manager operator will update the replicas of MaxScale object and related PetSets and Pods.
Let’s wait for MariaDBOpsRequest to be Successful. Run the following command to watch MariaDBOpsRequest CR,
$ watch kubectl get mariadbopsrequest -n demo
Every 2.0s: kubectl get mariadbopsrequest -n demo
NAME TYPE STATUS AGE
maxscale-horizontal-scale-up HorizontalScaling Successful 2m31s
We can see from the above output that the MariaDBOpsRequest has succeeded. Now, we are going to verify the number of replicas this database has from the MariaDB object, number of pods the petset have,
$ kubectl get mariadb -n demo md-replication -o json | jq '.spec.topology.maxscale.replicas'
4
$ kubectl get petset -n demo md-replication-mx -o json | jq '.spec.replicas'
4
From all the above outputs we can see that the replicas of the MaxScale server is 4. That means we have successfully scaled up the replicas of the MaxScale server.
Scale Down Replicas
Here, we are going to scale down the replicas of the cluster to meet the desired number of replicas after scaling.
Create MariaDBOpsRequest
In order to scale down the replicas of the MaxScale server, we have to create a MariaDBOpsRequest CR with our desired replicas. Below is the YAML of the MariaDBOpsRequest CR that we are going to create,
apiVersion: ops.kubedb.com/v1alpha1
kind: MariaDBOpsRequest
metadata:
name: maxscale-horizontal-scale-down
namespace: demo
spec:
type: HorizontalScaling
databaseRef:
name: md-replication
horizontalScaling:
maxscale: true
member: 3
Here,
spec.typespecifies that we are performingHorizontalScalingon our database.spec.databaseRef.namespecifies that we are performing horizontal scaling operation onmd-replicationdatabase.spec.horizontalScaling.maxscalespecifies that we are performing horizontal scaling operation on maxscale server. If false then horizontal scaling performs on mariadb database.spec.horizontalScaling.memberspecifies the desired replicas after scaling.
Let’s create the MariaDBOpsRequest CR we have shown above,
$ kubectl apply -f https://github.com/kubedb/docs/raw/v2025.8.31/docs/examples/mariadb/scaling/horizontal-scaling/mx-hscale-down.yaml
mariadbopsrequest.ops.kubedb.com/maxscale-horizontal-scale-down created
Verify Cluster replicas scaled down successfully
If everything goes well, KubeDB Ops-manager operator will update the replicas of MaxScale object and related PetSets and Pods.
Let’s wait for MariaDBOpsRequest to be Successful. Run the following command to watch MariaDBOpsRequest CR,
$ watch kubectl get mariadbopsrequest -n demo
Every 2.0s: kubectl get mariadbopsrequest -n demo
NAME TYPE STATUS AGE
maxscale-horizontal-scale-down HorizontalScaling Successful 55s
We can see from the above output that the MariaDBOpsRequest has succeeded. Now, we are going to verify the number of replicas MaxScale server has from the MariaDB object, number of pods the petset have,
$ kubectl get mariadb -n demo md-replication -o json | jq '.spec.topology.maxscale.replicas'
3
$ kubectl get petset -n demo md-replication-mx -o json | jq '.spec.replicas'
3
From all the above outputs we can see that the replicas of the cluster is 3. That means we have successfully scaled down the replicas of the MaxScale server.
Cleaning Up
To clean up the Kubernetes resources created by this tutorial, run:
$ kubectl delete mariadb -n demo md-replication
$ kubectl delete mariadbopsrequest -n demo maxscale-horizontal-scale-up maxscale-horizontal-scale-down
$ kubectl delete ns demo






























