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!"