qdrant
by apecloud
High-performance, massive-scale Vector Database for the next generation of AI.
About this chart
Qdrant
Qdrant is an open source (Apache-2.0 licensed), vector similarity search engine and vector database.
Features In KubeBlocks
Lifecycle Management
| Topology | Horizontalscaling | Vertical scaling | Expandvolume | Restart | Stop/Start | Configure | Expose | Switchover |
|---|---|---|---|---|---|---|---|---|
| cluster | Yes | Yes | Yes | Yes | Yes | No | Yes | N/A |
Backup and Restore
| Feature | Method | Description |
|---|---|---|
| Full Backup | datafile | uses HTTP API snapshot to create snapshot for all collections. |
Versions
| Major Versions | Description |
|---|---|
| 1.5 | 1.5.0 |
| 1.7 | 1.7.3 |
| 1.8 | 1.8.1,1.8.4 |
| 1.10 | 1.10.0 |
Prerequisites
-
Kubernetes cluster >= v1.21
-
kubectlinstalled, refer to K8s Install Tools -
Helm, refer to Installing Helm
-
KubeBlocks installed and running, refer to Install Kubeblocks
-
Qdrant Addon Enabled, refer to Install Addons
-
Create K8s Namespace
demo, to keep resources created in this tutorial isolated:kubectl create ns demo
Examples
Create
Create a Qdrant cluster with specified cluster definition
# cat examples/qdrant/cluster.yaml
apiVersion: apps.kubeblocks.io/v1
kind: Cluster
metadata:
name: qdrant-cluster
namespace: demo
spec:
# Specifies the behavior when a Cluster is deleted.
# Valid options are: [DoNotTerminate, Delete, WipeOut] (`Halt` is deprecated since KB 0.9)
# - `DoNotTerminate`: Prevents deletion of the Cluster. This policy ensures that all resources remain intact.
# - `Delete`: Extends the `Halt` policy by also removing PVCs, leading to a thorough cleanup while removing all persistent data.
# - `WipeOut`: An aggressive policy that deletes all Cluster resources, including volume snapshots and backups in external storage. This results in complete data removal and should be used cautiously, primarily in non-production environments to avoid irreversible data loss.
terminationPolicy: Delete
# Specifies the name of the ClusterDefinition to use when creating a Cluster.
# Note: DO NOT UPDATE THIS FIELD
# The value must be `qdrant` to create a Qdrant Cluster
clusterDef: qdrant
# Specifies the name of the ClusterTopology to be used when creating the
# Cluster.
# Valid options are: [cluster]
topology: cluster
componentSpecs:
- name: qdrant
# ServiceVersion specifies the version of the Service expected to be
# provisioned by this Component.
# Valid options are: [1.10.0,1.5.0,1.7.3,1.8.1,1.8.4]
serviceVersion: 1.10.0
# Update `replicas` to your need.
# Recommended values are: [3,5,7]
replicas: 3
# Specifies the resources required by the Component.
resources:
limits:
cpu: "0.5"
memory: "0.5Gi"
requests:
cpu: "0.5"
memory: "0.5Gi"
# Specifies a list of PersistentVolumeClaim templates that define the storage
# requirements for the Component.
volumeClaimTemplates:
# Refers to the name of a volumeMount defined in
# `componentDefinition.spec.runtime.containers[*].volumeMounts
- name: data
spec:
# The name of the StorageClass required by the claim.
# If not specified, the StorageClass annotated with
# `storageclass.kubernetes.io/is-default-class=true` will be used by default
storageClassName: ""
accessModes:
- ReadWriteOnce
resources:
requests:
# Set the storage size as needed
storage: 20Gi
kubectl apply -f examples/qdrant/cluster.yaml
Create with API key
Create a Qdrant cluster with service.api_key set through QDRANT__SERVICE__API_KEY:
kubectl apply -f examples/qdrant/cluster-with-api-key.yaml
You can configure the Qdrant API key in either of these ways:
# Qdrant environment variable. This has higher priority than config.yaml.
env:
- name: QDRANT__SERVICE__API_KEY
value: my-key-123456
# KubeBlocks configuration variable. This renders service.api_key into config.yaml.
configs:
- name: qdrant-config-template
variables:
service_api_key: my-key-123456
Qdrant environment variables have higher priority than config.yaml. Backup and restore scripts follow the same order: they use QDRANT__SERVICE__API_KEY when that env is present in the action container, then fall back to service.api_key from the mounted config.yaml.
Configure telemetry
Qdrant telemetry is disabled by default in config.yaml. You can override it through the KubeBlocks configuration variables API:
configs:
- name: qdrant-config-template
variables:
telemetry_disabled: "false"
Create with TLS
Create a Qdrant cluster with TLS enabled by the KubeBlocks Cluster TLS API:
kubectl apply -f examples/qdrant/cluster-with-tls.yaml
Create with TLS and API key
Create a Qdrant cluster with TLS enabled and service.api_key set through QDRANT__SERVICE__API_KEY:
kubectl apply -f examples/qdrant/cluster-with-tls-and-api-key.yaml
Horizontal scaling
[!Important] Qdrant uses the Raft consensus protocol to maintain consistency regarding the cluster topology and the collections structure. Make sure to have an odd number of replicas, such as 3, 5, 7, to avoid split-brain scenarios, after scaling out/in the cluster.
Scale-out
Horizontal scaling out cluster by adding ONE more replica:
# cat examples/qdrant/scale-out.yaml
apiVersion: operations.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: qdrant-scale-out
namespace: demo
spec:
# Specifies the name of the Cluster resource that this operation is targeting.
clusterName: qdrant-cluster
type: HorizontalScaling
# Lists HorizontalScaling objects, each specifying scaling requirements for a Component, including desired total replica counts, configurations for new instances, modifications for existing instances, and instance downscaling options
horizontalScaling:
# Specifies the name of the Component.
- componentName: qdrant
# Specifies the replica changes for scaling out components
scaleOut:
# Specifies the replica changes for the component.
# add one more replica to current component
replicaChanges: 1
kubectl apply -f examples/qdrant/scale-out.yaml
Scale-in
Horizontal scaling in cluster by deleting ONE replica:
# cat examples/qdrant/scale-in.yaml
apiVersion: operations.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: qdrant-scale-in
namespace: demo
spec:
# Specifies the name of the Cluster resource that this operation is targeting.
clusterName: qdrant-cluster
type: HorizontalScaling
# Lists HorizontalScaling objects, each specifying scaling requirements for a Component, including desired total replica counts, configurations for new instances, modifications for existing instances, and instance downscaling options
horizontalScaling:
# Specifies the name of the Component.
- componentName: qdrant
# Specifies the replica changes for scaling out components
scaleIn:
# Specifies the replica changes for the component.
# add one more replica to current component
replicaChanges: 1
kubectl apply -f examples/qdrant/scale-in.yaml
[!IMPORTANT] On scale-in, data will be redistributed among the remaining replicas. Make sure to have enough capacity to accommodate the data. The data redistribution process may take some time depending on the amount of data. It is handled by Qdrant
MemberLeaveoperation, and Pods won't be deleted until the data redistribution, i.e. theMemberLeaveactions completed successfully.
Scale-in/out using Cluster API
Alternatively, you can update the replicas field in the spec.componentSpecs.replicas section to your desired non-zero number.
# snippet of cluster.yaml
apiVersion: apps.kubeblocks.io/v1
kind: Cluster
spec:
componentSpecs:
- name: qdrant
replicas: 3 # Update `replicas` to your desired number
Vertical scaling
Vertical scaling up or down specified components requests and limits cpu or memory resource in the cluster
# cat examples/qdrant/verticalscale.yaml
apiVersion: operations.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: qdrant-verticalscaling
namespace: demo
spec:
# Specifies the name of the Cluster resource that this operation is targeting.
clusterName: qdrant-cluster
type: VerticalScaling
# Lists VerticalScaling objects, each specifying a component and its desired compute resources for vertical scaling.
verticalScaling:
- componentName: qdrant
# VerticalScaling refers to the process of adjusting the compute resources (e.g., CPU, memory) allocated to a Component. It defines the parameters required for the operation.
requests:
cpu: '1'
memory: 1Gi
limits:
cpu: '1'
memory: 1Gi
kubectl apply -f examples/qdrant/verticalscale.yaml
Scale-up/down using Cluster API
Alternatively, you may update spec.componentSpecs.resources field to the desired resources for vertical scale.
# snippet of cluster.yaml
apiVersion: apps.kubeblocks.io/v1
kind: Cluster
spec:
componentSpecs:
- name: qdrant
componentDef: qdrant
replicas: 3
resources:
requests:
cpu: "1" # Update the resources to your need.
memory: "2Gi" # Update the resources to your need.
limits:
cpu: "2" # Update the resources to your need.
memory: "4Gi" # Update the resources to your need.
Expand volume
[!NOTE] Make sure the storage class you use supports volume expansion.
Check the storage class with following command:
kubectl get storageclass
If the ALLOWVOLUMEEXPANSION column is true, the storage class supports volume expansion.
To increase size of volume storage with the specified components in the cluster
Increase size of volume storage with the specified components in the cluster
# cat examples/qdrant/volumeexpand.yaml
apiVersion: operations.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: qdrant-volumeexpansion
namespace: demo
spec:
# Specifies the name of the Cluster resource that this operation is targeting.
clusterName: qdrant-cluster
type: VolumeExpansion
# Lists VolumeExpansion objects, each specifying a component and its corresponding volumeClaimTemplates that requires storage expansion.
volumeExpansion:
# Specifies the name of the Component.
- componentName: qdrant
# volumeClaimTemplates specifies the storage size and volumeClaimTemplate name.
volumeClaimTemplates:
- name: data
storage: 30Gi
kubectl apply -f examples/qdrant/volumeexpand.yaml
Volume expansion using Cluster API
Alternatively, you may update the spec.componentSpecs.volumeClaimTemplates.spec.resources.requests.storage field to the desired size.
# snippet of cluster.yaml
apiVersion: apps.kubeblocks.io/v1
kind: Cluster
spec:
componentSpecs:
- name: qdrant
componentDef: qdrant
replicas: 3
volumeClaimTemplates:
- name: data
spec:
storageClassName: ""
accessModes:
- ReadWriteOnce
resources:
requests:
# specify new size, and make sure it is larger than the current size
storage: 30Gi
Restart
Restart the specified components in the cluster
# cat examples/qdrant/restart.yaml
apiVersion: operations.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: qdrant-restart
namespace: demo
spec:
# Specifies the name of the Cluster resource that this operation is targeting.
clusterName: qdrant-cluster
type: Restart
# Lists Components to be restarted. ComponentOps specifies the Component to be operated on.
restart:
# Specifies the name of the Component.
- componentName: qdrant
kubectl apply -f examples/qdrant/restart.yaml
Stop
Stop the cluster and release all the pods of the cluster, but the storage will be reserved
# cat examples/qdrant/stop.yaml
apiVersion: operations.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: qdrant-stop
namespace: demo
spec:
# Specifies the name of the Cluster resource that this operation is targeting.
clusterName: qdrant-cluster
type: Stop
kubectl apply -f examples/qdrant/stop.yaml
Start
Start the stopped cluster
# cat examples/qdrant/start.yaml
apiVersion: operations.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: qdrant-start
namespace: demo
spec:
# Specifies the name of the Cluster resource that this operation is targeting.
clusterName: qdrant-cluster
type: Start
kubectl apply -f examples/qdrant/start.yaml
Backup
[!NOTE] Before you start, please create a
BackupRepoto store the backup data. Refer to BackupRepo for more details.
The backup method uses the snapshot API to create a snapshot for all collections. It works as follows:
- Retrieve all Qdrant collections
- For each collection, create a snapshot, validate the snapshot, and push it to the backup repository
To create a backup for the cluster:
# cat examples/qdrant/backup.yaml
apiVersion: dataprotection.kubeblocks.io/v1alpha1
kind: Ba
Deploy qdrant with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has qdrant on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartqdrant is pinned at v1.2.0-alpha.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply