From ff7e1adc1901695bf6cfe53b4761034a97b796df Mon Sep 17 00:00:00 2001 From: Bastian Hofmann Date: Tue, 29 Aug 2023 11:47:13 +0200 Subject: [PATCH] Allow annotations on volumeClaimTemplate of qdrant statefulset (#63) Fixes https://github.com/qdrant/qdrant-helm/issues/45 Signed-off-by: Bastian Hofmann --- charts/qdrant/templates/statefulset.yaml | 4 +++ charts/qdrant/values.yaml | 1 + test/qdrant_annotations_test.go | 40 ++++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 test/qdrant_annotations_test.go diff --git a/charts/qdrant/templates/statefulset.yaml b/charts/qdrant/templates/statefulset.yaml index ade1cbc..4f759d5 100644 --- a/charts/qdrant/templates/statefulset.yaml +++ b/charts/qdrant/templates/statefulset.yaml @@ -149,6 +149,10 @@ spec: name: qdrant-storage labels: app: {{ template "qdrant.name" . }} + {{- with .Values.persistence.annotations }} + annotations: + {{- toYaml . | nindent 10 }} + {{- end }} spec: storageClassName: {{ .Values.persistence.storageClassName }} accessModes: diff --git a/charts/qdrant/values.yaml b/charts/qdrant/values.yaml index 097853d..e940466 100644 --- a/charts/qdrant/values.yaml +++ b/charts/qdrant/values.yaml @@ -94,6 +94,7 @@ affinity: {} persistence: accessModes: ["ReadWriteOnce"] size: 10Gi + annotations: {} # storageClassName: local-path # only supported for single node qdrant clusters. diff --git a/test/qdrant_annotations_test.go b/test/qdrant_annotations_test.go new file mode 100644 index 0000000..28baff2 --- /dev/null +++ b/test/qdrant_annotations_test.go @@ -0,0 +1,40 @@ +package test + +import ( + "path/filepath" + "strings" + "testing" + + "github.com/gruntwork-io/terratest/modules/helm" + "github.com/gruntwork-io/terratest/modules/k8s" + "github.com/gruntwork-io/terratest/modules/logger" + "github.com/gruntwork-io/terratest/modules/random" + "github.com/stretchr/testify/require" + appsv1 "k8s.io/api/apps/v1" +) + +func TestPvcAnnotations(t *testing.T) { + t.Parallel() + + helmChartPath, err := filepath.Abs("../charts/qdrant") + releaseName := "qdrant" + require.NoError(t, err) + + namespaceName := "qdrant-" + strings.ToLower(random.UniqueId()) + logger.Log(t, "Namespace: %s\n", namespaceName) + + options := &helm.Options{ + SetJsonValues: map[string]string{ + "persistence.annotations": `{"test": "value"}`, + }, + KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName), + } + + output := helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/statefulset.yaml"}) + + var statefulSet appsv1.StatefulSet + helm.UnmarshalK8SYaml(t, output, &statefulSet) + + require.Contains(t, statefulSet.Spec.VolumeClaimTemplates[0].ObjectMeta.Annotations, "test") + require.Equal(t, statefulSet.Spec.VolumeClaimTemplates[0].ObjectMeta.Annotations["test"], "value") +}