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 Scaling Milvus

This guide will show you how to use the KubeDB Ops-manager operator to horizontally scale the roles of a distributed Milvus database.

Horizontal scaling is distributed-only. A Standalone Milvus is a single all-in-one workload (one PetSet, one replica) and cannot be horizontally scaled. To scale out, deploy Milvus in Distributed mode.

Before You Begin

Note: The yaml files used in this tutorial are stored in docs/guides/milvus/scaling/horizontal-scaling/yamls folder in GitHub repository kubedb/docs.

Deploy a Distributed Milvus

Deploy the distributed database (milvus-cluster) and wait until it is Ready (see the distributed quickstart). By default each role runs a single replica.

$ kubectl get petset milvus-cluster-proxy milvus-cluster-streamingnode -n demo -o custom-columns=NAME:.metadata.name,REPLICAS:.spec.replicas
NAME                           REPLICAS
milvus-cluster-proxy           1
milvus-cluster-streamingnode   1

Apply the HorizontalScaling OpsRequest

The sample changes only proxy and streamingnode. (The provided sample requests 1 for each; because the default is already 1, this walkthrough requests 2 to demonstrate a scale-up.)

horizontal-scaling-distributed.yaml

apiVersion: ops.kubedb.com/v1alpha1
kind: MilvusOpsRequest
metadata:
  name: milvus-hscale-up
  namespace: demo
spec:
  type: HorizontalScaling
  databaseRef:
    name: milvus-cluster
  horizontalScaling:
    topology:
      proxy: 2
      streamingnode: 2

Here, spec.horizontalScaling.topology carries the desired replica count per role. The API also accepts mixcoord, querynode and dataNode; this sample only scales proxy and streamingnode, but the other roles are scaled the same way.

$ kubectl apply -f horizontal-scaling-distributed.yaml
milvusopsrequest.ops.kubedb.com/milvus-hscale-up created

Watch Progress and Verify

$ kubectl get milvusopsrequest milvus-hscale-up -n demo
NAME               TYPE                STATUS       AGE
milvus-hscale-up   HorizontalScaling   Successful   57s
$ kubectl describe milvusopsrequest milvus-hscale-up -n demo
...
Status:
  Conditions:
    Message:  Milvus ops-request has started to horizontally scale the Milvus nodes
    Reason:   HorizontalScaling
    Type:     HorizontalScaling
    Message:  Successfully Scaled Up proxy
    Reason:   ScaleUpProxy
    Type:     ScaleUpProxy
    Message:  pod readyproxy; ConditionStatus:True; PodName:milvus-cluster-proxy-1
    Type:     PodReadyproxy--milvus-cluster-proxy-1
    Message:  Successfully Scaled Up streamingnode
    Reason:   ScaleUpStreamingNode
    Type:     ScaleUpStreamingNode
  Phase:      Successful

Both roles now run two replicas:

$ kubectl get petset milvus-cluster-proxy milvus-cluster-streamingnode -n demo -o custom-columns=NAME:.metadata.name,REPLICAS:.spec.replicas
NAME                           REPLICAS
milvus-cluster-proxy           2
milvus-cluster-streamingnode   2

$ kubectl get pods -n demo -l app.kubernetes.io/instance=milvus-cluster | grep -E 'proxy|streamingnode'
milvus-cluster-proxy-0           1/1     Running   0          70s
milvus-cluster-proxy-1           1/1     Running   0          39s
milvus-cluster-streamingnode-0   1/1     Running   0          119s
milvus-cluster-streamingnode-1   1/1     Running   0          18s

Scaling down works the same way — set lower replica counts in spec.horizontalScaling.topology.

Cleaning up

$ kubectl delete milvusopsrequest -n demo milvus-hscale-up
$ kubectl delete milvus.kubedb.com -n demo milvus-cluster
$ kubectl delete ns demo

Next Steps