From 4052947cd89b5bcb226d7ea84ffd725085a03960 Mon Sep 17 00:00:00 2001 From: Dmitrii Ganochenko Date: Sat, 13 Jan 2024 17:43:38 +0100 Subject: [PATCH 1/2] collection params --- deploy/crds/crd-qdrantcollection.yaml | 4 ++++ deploy/operator.yaml | 3 ++- docs/qdrantcollections-api.md | 2 ++ examples/qdrant-collection-complete.yaml | 16 ++++++++++++++-- examples/qdrant-collection-replication.yaml | 11 +++++++++++ src/collection-ops.js | 10 ++++++++-- src/package-lock.json | 4 ++-- src/package.json | 2 +- src/tools/cert-generate.sh | 2 +- 9 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 examples/qdrant-collection-replication.yaml diff --git a/deploy/crds/crd-qdrantcollection.yaml b/deploy/crds/crd-qdrantcollection.yaml index fdc5bed..98537f6 100644 --- a/deploy/crds/crd-qdrantcollection.yaml +++ b/deploy/crds/crd-qdrantcollection.yaml @@ -57,4 +57,8 @@ spec: onDisk: type: boolean default: true + config: + description: "Custom Qdrant collection configuration" + type: object + x-kubernetes-preserve-unknown-fields: true diff --git a/deploy/operator.yaml b/deploy/operator.yaml index 87e666a..2dd3ec4 100644 --- a/deploy/operator.yaml +++ b/deploy/operator.yaml @@ -75,9 +75,10 @@ spec: labels: *labels spec: serviceAccountName: qdrant-operator-sa + terminationGracePeriodSeconds: 5 containers: - name: operator - image: docker.io/dganochenko/qdrant-operator:0.1.4 + image: docker.io/dganochenko/qdrant-operator:0.1.5 imagePullPolicy: Always # debug # command: ["/bin/sh"] diff --git a/docs/qdrantcollections-api.md b/docs/qdrantcollections-api.md index 558737d..7934b9e 100644 --- a/docs/qdrantcollections-api.md +++ b/docs/qdrantcollections-api.md @@ -29,4 +29,6 @@ spec: - **replicationFactor** (integer, optional): Number of replicas for each shard in the collection. +- **config** (object, optional): Additional configuration for the Qdrant collection, including [indexing](https://qdrant.tech/documentation/concepts/indexing/#vector-index), [quantization](https://qdrant.tech/documentation/guides/quantization/) and [optimizer](https://qdrant.tech/documentation/concepts/optimizer/) parameters. + Feel free to customize the values based on your specific requirements when creating or updating the QdrantCollection custom resource in your Kubernetes cluster. diff --git a/examples/qdrant-collection-complete.yaml b/examples/qdrant-collection-complete.yaml index eb815fa..564ade9 100644 --- a/examples/qdrant-collection-complete.yaml +++ b/examples/qdrant-collection-complete.yaml @@ -5,7 +5,19 @@ metadata: spec: cluster: my-cluster vectorSize: 10 - onDisk: true + onDisk: false shardNumber: 6 replicationFactor: 2 - + config: + hnsw_config: + m: 16 + ef_construct: 100 + full_scan_threshold: 10000 + optimizers_config: + deleted_threshold: 0.2 + vacuum_min_vector_number: 1000 + quantization_config: + scalar: + type: int8 + quantile: 0.5 + always_ram: true diff --git a/examples/qdrant-collection-replication.yaml b/examples/qdrant-collection-replication.yaml new file mode 100644 index 0000000..eb815fa --- /dev/null +++ b/examples/qdrant-collection-replication.yaml @@ -0,0 +1,11 @@ +apiVersion: qdrant.operator/v1alpha1 +kind: QdrantCollection +metadata: + name: my-collection +spec: + cluster: my-cluster + vectorSize: 10 + onDisk: true + shardNumber: 6 + replicationFactor: 2 + diff --git a/src/collection-ops.js b/src/collection-ops.js index 9641713..f36af9e 100644 --- a/src/collection-ops.js +++ b/src/collection-ops.js @@ -40,7 +40,7 @@ export const createCollection = async (apiObj, k8sCustomApi, k8sCoreApi) => { k8sCustomApi, k8sCoreApi ); - const body = { + var body = { vectors: { size: apiObj.spec.vectorSize, distance: 'Cosine', @@ -49,6 +49,9 @@ export const createCollection = async (apiObj, k8sCustomApi, k8sCoreApi) => { shard_number: apiObj.spec.shardNumber, replication_factor: apiObj.spec.replicationFactor }; + if (typeof apiObj.spec.config !== 'undefined') { + body = { ...body, ...apiObj.spec.config }; + } try { log( `Trying to create a Collection "${name}" in the Cluster "${apiObj.spec.cluster}"...` @@ -72,7 +75,7 @@ export const updateCollection = async (apiObj, k8sCustomApi, k8sCoreApi) => { k8sCustomApi, k8sCoreApi ); - const body = { + var body = { vectors: { '': { size: apiObj.spec.vectorSize, @@ -83,6 +86,9 @@ export const updateCollection = async (apiObj, k8sCustomApi, k8sCoreApi) => { shard_number: apiObj.spec.shardNumber, replication_factor: apiObj.spec.replicationFactor }; + if (typeof apiObj.spec.config !== 'undefined') { + body = { ...body, ...apiObj.spec.config }; + } try { log( `Trying to update a Collection "${name}" in the Cluster "${apiObj.spec.cluster}"...` diff --git a/src/package-lock.json b/src/package-lock.json index e33f19d..82e7c52 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -1,12 +1,12 @@ { "name": "qdrant-operator", - "version": "0.1.4", + "version": "0.1.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "qdrant-operator", - "version": "0.1.4", + "version": "0.1.5", "license": "MIT", "dependencies": { "@kubernetes/client-node": "^0.20.0", diff --git a/src/package.json b/src/package.json index c902ea7..c147198 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "qdrant-operator", - "version": "0.1.4", + "version": "0.1.5", "description": "Kubernetes operator for Qdrant", "main": "index.js", "type": "module", diff --git a/src/tools/cert-generate.sh b/src/tools/cert-generate.sh index d890b9e..6772b15 100755 --- a/src/tools/cert-generate.sh +++ b/src/tools/cert-generate.sh @@ -81,5 +81,5 @@ openssl req -nodes -sha256 -new -key key.pem \ -extensions v3_req -extfile csr.conf \ -CAcreateserial -out cert.pem 2>/dev/null -echo "Certificates for \"${NAME}\" are ready!" +echo -n "Certificates for \"${NAME}\" are ready!" From cf5d5388ae4b201dfef2639eae1ebc197722d365 Mon Sep 17 00:00:00 2001 From: Dmitrii Ganochenko Date: Sat, 13 Jan 2024 17:46:31 +0100 Subject: [PATCH 2/2] update changelog --- changelog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/changelog.md b/changelog.md index 12d0e0a..32d1954 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ # Changelog +## qdrant-operator-0.1.5 (2024-01-13) + +- Added support for additional collection params with the `spec.config` spec. See the example: [examples/qdrant-collection-complete.yaml]. + ## qdrant-operator-0.1.4 (2024-01-12) - Refactor the settingStatus function code.