Get started
Milvus is a high-performance vector database built for scale. It is used by AI applications to organize and search through large amount of unstructured data, such as text, images and multi-modal information.
Before exploring the chart characteristics, let’s start by deploying the default configuration:
helm install <release-name> oci://dp.apps.rancher.io/charts/milvus \
--set global.imagePullSecrets={application-collection}Please check our authentication guide if you need to configure Application Collection OCI credentials in your Kubernetes cluster.
Quick start
We will describe how to get quickly started with Milvus in just a few steps, using the Milvus SDK for Python , by creating a collection of vectors and their associated metadata, and perform a semantic search on the data, following the steps described at Quick start with Milvus .
-
Ensure that all Milvus pods have been deployed successfully:
kubectl get podsA successful default deployment will look like this, with all pods in ready state:
NAME READY STATUS RESTARTS AGE milvus-datanode-7578778f89-rtpgr 1/1 Running 2 (2m4s ago) 2m26s milvus-etcd-0 1/1 Running 0 2m26s milvus-etcd-1 1/1 Running 0 2m26s milvus-etcd-2 1/1 Running 0 2m26s milvus-kafka-broker-0 1/1 Running 0 2m26s milvus-kafka-broker-1 1/1 Running 0 2m25s milvus-kafka-broker-2 1/1 Running 0 2m25s milvus-kafka-controller-0 1/1 Running 0 2m26s milvus-kafka-controller-1 1/1 Running 0 2m25s milvus-kafka-controller-2 1/1 Running 0 2m25s milvus-minio-0 1/1 Running 0 2m26s milvus-minio-1 1/1 Running 0 2m26s milvus-minio-2 1/1 Running 0 2m26s milvus-minio-3 1/1 Running 0 2m25s milvus-mixcoord-b64f49c49-8t8mk 1/1 Running 2 (2m4s ago) 2m26s milvus-proxy-c98988f57-7hdvc 1/1 Running 2 (2m4s ago) 2m26s milvus-querynode-65955f49dd-mz8gv 1/1 Running 2 (2m4s ago) 2m26s milvus-streamingnode-859c955695-thrqp 1/1 Running 2 (2m4s ago) 2m26s -
Install the Milvus SDK for Python and the Milvus model library for Python to your local environment:
pip3 install -U pymilvus pip3 install -U "pymilvus[model]" -
Expose the Milvus server to your environment. You can do this with
kubectl port-forward:kubectl port-forward service/milvus 19530:19530 -
Enter the Python console:
python3 -
From the Python console, connect to the cluster using the default credentials:
from pymilvus import MilvusClient client = MilvusClient(uri="http://localhost:19530", token="root:Milvus") -
Create a sample collection:
client.create_collection( collection_name="demo_collection", dimension=768, # The vectors we will use in this demo has 768 dimensions ) -
Generate vector embeddings with the default model library:
from pymilvus import model # Load the default model library, this will download a small embedding model "paraphrase-albert-small-v2" from Hugging Face (~50MB) # This model maps sentences & paragraphs to a 768 dimensional dense vector space and can be used for tasks like clustering or semantic search embedding_fn = model.DefaultEmbeddingFunction() # Generate vectors from a sample set of strings docs = [ "Artificial intelligence was founded as an academic discipline in 1956.", "Alan Turing was the first person to conduct substantial research in AI.", "Born in Maida Vale, London, Turing was raised in southern England.", ] vectors = embedding_fn.encode_documents(docs) # The output vector has 768 dimensions, matching the collection that we just created print("Dim:", embedding_fn.dim, vectors[0].shape) # Output: Dim: 768 (768,) # Each entity has id, vector representation, raw text, and a subject label that we use to demo metadata filtering later data = [ {"id": i, "vector": vectors[i], "text": docs[i], "subject": "history"} for i in range(len(vectors)) ] print("Data has", len(data), "entities, each with fields: ", data[0].keys()) # Output: Data has 3 entities, each with fields: dict_keys(['id', 'vector', 'text', 'subject']) print("Vector dim:", len(data[0]["vector"])) # Output: Vector dim: 768 -
Insert the data into the collection:
res = client.insert(collection_name="demo_collection", data=data) print(res) # Output: {'insert_count': 3, 'ids': [0, 1, 2]} -
Perform a semantic search, by encoding the search query into vectors and conduct a vector similarity search:
query_vectors = embedding_fn.encode_queries(["Who is Alan Turing?"]) res = client.search( collection_name="demo_collection", # target collection data=query_vectors, # query vectors limit=2, # number of returned entities output_fields=["text", "subject"], # specifies fields to be returned ) print(res) # Output: # data: [[{'id': 2, 'distance': 0.5859943628311157, 'entity': {'text': 'Born in Maida Vale, London, Turing was raised in ...
Chart overview
Our Milvus chart is based on the official milvus chart and adapted to include our best practices. As such, most chart-related documentation provided by upstream will work out of the box with our chart. You can check the official documentation here .
By default, the chart will deploy a basic Milvus cluster with a data node, a proxy node, a query node and a streaming node, as well as a mix coordinator node, per the Milvus architecture .
The following features from the official Milvus chart are not supported, and have been removed from our chart:
- Milvus WebUI.
- Apache Pulsar 3.x integration.
- Text Embeddings Interface integration.
Chart configuration
To view the supported configuration options and documentation, run:
helm show values oci://dp.apps.rancher.io/charts/milvusRead more on how to configure Milvus with Helm charts .
Authentication
By default, the Milvus Helm chart does not enforce authentication, but it creates a user root with the Milvus password.
You can enforce authentication by deploying Milvus with the following configuration:
extraConfigFiles:
user.yaml: |+
common:
security:
authorizationEnabled: trueScale Milvus
By default, our Helm chart deploys a Milvus cluster with the following components:
- Four Milvus nodes, one per component type (data, proxy, query and streaming). They can individually be disabled with
<component>Node.enabled=falseand scaled with<component>Node.replicas=1. For example, the option names for the data node would bedataNode.enabledanddataNode.replicas, respectively. - One mix coordinator node, which can be used with all Milvus component types.
- An Apache Kafka cluster with 3 broker nodes and 3 controller nodes. The number of Apache Kafka replicas can be configured with the
kafka.cluster.nodeCount.brokerandkafka.cluster.nodeCount.controlleroptions for the broker and controller nodes, respectively. - An etcd cluster with 3 nodes. The number of etcd replicas can be configured with
etcd.replicaCount. - A MinIO cluster with 4 nodes. The number of MinIO replicas can be configured with
minio.replicas.
The following nodes are not enabled by default:
- Index nodes.
- Coordinator nodes for root, query, index and data nodes. These can be enabled by setting
<component>Coordinator.enabled=true. For example, to enable a root coordinator, setrootCoordinator.enabled=true. - A Milvus-CDC node. Milvus-CDC is a user-friendly tool that can capture and synchronize incremental data in Milvus instances, and only supports
one replica. To enable Milvus-CDC, set
cdc.enabled=true. - Standalone nodes. Requires disabling cluster mode via
cluster.enabled=false. This will make all Milvus nodes be standalone nodes. Standalone nodes can be scaled by setting thestandalone.replicasoption.
The scaling configuration for the Milvus components can be configured in the following way:
# Milvus standalone nodes configuration
# By default, Milvus cluster is enabled, disabling standalone nodes
cluster:
enabled: true # Disable to enable Milvus standalone nodes
standalone:
replicas: 1
# Streaming nodes configuration
streaming:
enabled: true
streamingNode:
replicas: 1
# Proxy, query, index and data nodes configuration
proxy:
enabled: true
replicas: 1
queryNode:
enabled: true
replicas: 1
indexNode:
enabled: false
replicas: 1
dataNode:
enabled: true
replicas: 1
# Coordinator nodes configuration
mixCoordinator:
enabled: true
replicas: 1
rootCoordinator:
enabled: false
replicas: 1
queryCoordinator:
enabled: false
replicas: 1
indexCoordinator:
enabled: false
replicas: 1
dataCoordinator:
enabled: false
replicas: 1
# Milvus-CDC configuration
# Currently only supports 1 replica
cdc:
enabled: false
# etcd configuration
etcd:
replicaCount: 3
# Apache Kafka configuration
kafka:
cluster:
nodeCount:
controller: 3
broker: 3
# MinIO configuration
minio:
replicas: 4Operations
Connect to the cluster
Follow these steps to connect to Milvus, using the Python SDK for Milvus Vector Database :
-
First, install the Python SDK for Milvus if you haven’t already:
pip3 install -U pymilvus -
Expose the Milvus server to your environment. You can do this with
kubectl port-forward:kubectl port-forward service/milvus 19530:19530 -
Enter the Python console:
python3 -
Execute the following Python code in the Python console. Remember to replace the
USERNAMEandPASSWORDplaceholders with the user credentials:from pymilvus import MilvusClient client = MilvusClient( uri='http://localhost:19530', token="USERNAME:PASSWORD" ) -
Check that the connection succeeded by performing a query to describe the current user:
client.describe_user('root') # Output: {'user_name': 'root', 'roles': ()}
Change user credentials
Follow these steps to change a user credentials in Milvus:
-
Update the credentials for the desired user. The below snipped can be executed in a Python console to update the default password for the Milvus
rootuser. Remember to replace thePASSWORDplaceholder):client.update_password( user_name="root", old_password="Milvus", new_password="PASSWORD" )
Create additional users
To create more users, follow these steps:
-
Create a new user. Once connected to the Milvus server, you can do it with the following commands in the Python console (remember to replace the
USERNAMEandPASSWORDplaceholders):# Create a user client.create_user( user_name="USERNAME", password="PASSWORD", ) -
Verify that the user has been created:
client.describe_user("USERNAME") # Output: {'user_name': 'USERNAME', 'roles': ()}
Upgrade the chart
An in-place upgrade of your Milvus installation can be performed using the built-in Helm upgrade workflow:
helm upgrade <release-name> oci://dp.apps.rancher.io/charts/milvus \
--set global.imagePullSecrets={application-collection}Be aware that changes from version to version may include breaking changes in Milvus itself or in the Helm chart templates. In other cases, the upgrade process may require additional steps to be performed. Refer to the official release notes and always check the upstream Helm chart’s compatibility notice before proceeding with an upgrade.
Uninstall the chart
Removing an installed Milvus instance is simple:
helm uninstall <release-name>The Milvus nodes are deployed as Deployments , hence using Volume Claim Templates to store your most precious resource in a database installation: your data. These PVCs are not directly controlled by Helm and they are not removed when uninstalling the related chart.
When you are ready to remove the PVCs and your data, you will need to explicitly delete them:
kubectl delete pvc --selector app.kubernetes.io/instance=<release-name>