From 4e06afea1aad45ee626d917e67183eecf985d84c Mon Sep 17 00:00:00 2001 From: Moustafa Nawar Date: Mon, 24 Oct 2022 20:52:12 +0200 Subject: [PATCH] support single node snapshots restoration --- README.md | 6 ++++++ templates/configmap.yaml | 5 +++++ templates/statefulset.yaml | 5 +++++ values.yaml | 7 +++++++ 4 files changed, 23 insertions(+) diff --git a/README.md b/README.md index e40854d..84fdcf8 100644 --- a/README.md +++ b/README.md @@ -61,3 +61,9 @@ Increase the number of replicas to the desired number of nodes and set `config.c Depending on your environment or cloud provider you might need to change the service in the `values.yaml` as well. For example on AWS EKS you would need to change the `cluster.type` to `NodePort`. + +### Snapshot Restoration + +Disclaimer: Snapshot restoration is only supported for single qdrant node setups + +To restore a snapshot create a Persistent Volume and a Persistent Volume Claim using a storage class according to your setup, copy the snapshots to the PV, enable snapshot restoration along with the snapshot file names and pvc name in values.yaml file and run the helm install command. diff --git a/templates/configmap.yaml b/templates/configmap.yaml index 27c0555..ea49a3e 100644 --- a/templates/configmap.yaml +++ b/templates/configmap.yaml @@ -6,11 +6,16 @@ data: initialize.sh: | #!/bin/sh SET_INDEX=${HOSTNAME##*-} + {{- if and (.Values.snapshotRestoration.enabled) (eq (.Values.replicaCount | quote) (1 | quote)) }} + echo "Starting initializing for pod $SET_INDEX and snapshots restoration" + ./qdrant {{ range .Values.snapshotRestoration.snapshots }} --snapshot {{ . }} {{ end }} + {{- else }} echo "Starting initializing for pod $SET_INDEX" if [ "$SET_INDEX" = "0" ]; then ./qdrant --uri 'http://{{ include "qdrant.fullname" . }}-0.{{ include "qdrant.fullname" . }}-headless:6335' else ./qdrant --bootstrap 'http://{{ include "qdrant.fullname" . }}-0.{{ include "qdrant.fullname" . }}-headless:6335' --uri 'http://{{ include "qdrant.fullname" . }}-'"$SET_INDEX"'.{{ include "qdrant.fullname" . }}-headless:6335' fi + {{ end }} production.yaml: | {{- toYaml .Values.config | nindent 4 }} diff --git a/templates/statefulset.yaml b/templates/statefulset.yaml index a777f2e..aba7dda 100644 --- a/templates/statefulset.yaml +++ b/templates/statefulset.yaml @@ -84,6 +84,8 @@ spec: - name: qdrant-config mountPath: /qdrant/config/production.yaml subPath: production.yaml + - name: qdrant-snapshots + mountPath: /qdrant/snapshots {{- with .Values.nodeSelector }} nodeSelector: @@ -102,6 +104,9 @@ spec: configMap: name: {{ include "qdrant.fullname" . }} defaultMode: 0755 + - name: qdrant-snapshots + persistentVolumeClaim: + claimName: {{ .Values.snapshotRestoration.pvcName }} volumeClaimTemplates: - metadata: diff --git a/values.yaml b/values.yaml index 1c08c87..526a299 100644 --- a/values.yaml +++ b/values.yaml @@ -68,6 +68,13 @@ persistence: size: 1Gi #storageClassName: local-path +#only supported for single node qdrant clusters. +snapshotRestoration: + enabled: true + pvcName: snapshots-pvc + snapshots: + - /qdrant/snapshots/test_collection/test_collection-2022-10-24-13-56-50.snapshot:test_collection + #modification example for configuration to overwrite defaults config: cluster: