Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Linting is done with `helm lint`.

Prerequisites:

* Helm
* Helm (version >= 3.10)

```bash
brew install helm
Expand All @@ -26,7 +26,7 @@ Unit tests are in the `./test` directory and written in Go with [terratest](http

Prerequisites:

* Go
* Go (version >= 1.24.1)

```bash
brew install go
Expand Down
11 changes: 11 additions & 0 deletions charts/qdrant/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ app.kubernetes.io/name: {{ include "qdrant.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Additional (global) labels
*/}}
{{- define "qdrant.additionalLabels" -}}
{{- with .Values.additionalLabels }}
{{- range $key, $value := . }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
Expand Down
1 change: 1 addition & 0 deletions charts/qdrant/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
name: {{ include "qdrant.fullname" . }}
labels:
{{- include "qdrant.labels" . | nindent 4 }}
{{- include "qdrant.additionalLabels" . | nindent 4 }}
{{- with .Values.additionalAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
1 change: 1 addition & 0 deletions charts/qdrant/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
name: {{ include "qdrant.fullname" . }}
labels:
{{- include "qdrant.labels" . | nindent 4 }}
{{- include "qdrant.additionalLabels" . | nindent 4 }}
{{- with .Values.ingress.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Expand Down
1 change: 1 addition & 0 deletions charts/qdrant/templates/pdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
name: {{ include "qdrant.fullname" . }}
labels:
{{- include "qdrant.labels" . | nindent 4 }}
{{- include "qdrant.additionalLabels" . | nindent 4 }}
{{- with .Values.additionalAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
1 change: 1 addition & 0 deletions charts/qdrant/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
name: {{ include "qdrant.fullname" . }}-apikey
labels:
{{- include "qdrant.labels" . | nindent 4 }}
{{- include "qdrant.additionalLabels" . | nindent 4 }}
{{- with .Values.additionalAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
1 change: 1 addition & 0 deletions charts/qdrant/templates/service-headless.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
name: {{ include "qdrant.fullname" . }}-headless
labels:
{{- include "qdrant.labels" . | nindent 4 }}
{{- include "qdrant.additionalLabels" . | nindent 4 }}
app.kubernetes.io/component: cluster-discovery
{{- with .Values.service.additionalLabels }}
{{- toYaml . | nindent 4 }}
Expand Down
1 change: 1 addition & 0 deletions charts/qdrant/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
name: {{ include "qdrant.fullname" . }}
labels:
{{- include "qdrant.labels" . | nindent 4 }}
{{- include "qdrant.additionalLabels" . | nindent 4 }}
{{- with .Values.service.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Expand Down
3 changes: 2 additions & 1 deletion charts/qdrant/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ metadata:
{{- end }}
{{- end }}
labels:
{{- include "qdrant.labels" . | nindent 4 }}
{{- include "qdrant.labels" . | nindent 4 }}
{{- include "qdrant.additionalLabels" . | nindent 4 }}
1 change: 1 addition & 0 deletions charts/qdrant/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ apiVersion: monitoring.coreos.com/v1
metadata:
labels:
{{- include "qdrant.labels" . | nindent 4 }}
{{- include "qdrant.additionalLabels" . | nindent 4 }}
{{- with .Values.metrics.serviceMonitor.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Expand Down
5 changes: 2 additions & 3 deletions charts/qdrant/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ metadata:
name: {{ include "qdrant.fullname" . }}
labels:
{{- include "qdrant.labels" . | nindent 4 }}
{{- with .Values.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- include "qdrant.additionalLabels" . | nindent 4 }}
{{- with .Values.additionalAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand All @@ -30,6 +28,7 @@ spec:
{{- end }}
labels:
{{- include "qdrant.selectorLabels" . | nindent 8 }}
{{- include "qdrant.additionalLabels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand Down
2 changes: 2 additions & 0 deletions charts/qdrant/templates/tests/test-db-interaction.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
name: "{{ include "qdrant.fullname" . }}-test-db-interaction"
labels:
{{- include "qdrant.labels" . | nindent 4 }}
{{- include "qdrant.additionalLabels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
{{- with .Values.additionalAnnotations }}
Expand Down Expand Up @@ -52,6 +53,7 @@ metadata:
name: "{{ include "qdrant.fullname" . }}-test-db-interaction"
labels:
{{- include "qdrant.labels" . | nindent 4 }}
{{- include "qdrant.additionalLabels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
{{- with .Values.additionalAnnotations }}
Expand Down
3 changes: 3 additions & 0 deletions charts/qdrant/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ args: ["./config/initialize.sh"]
env: []
# - name: QDRANT_ALLOW_RECOVERY_MODE
# value: true
additionalLabels: {}

# checks - Readiness and liveness checks can only be enabled for either http (REST) or grpc (multiple checks not supported)
# grpc checks are only available from k8s 1.24+ so as of per default we check http
Expand Down Expand Up @@ -183,6 +184,8 @@ config:
enable_tls: false
consensus:
tick_period_ms: 100
service:
enable_tls: false

sidecarContainers: []
# sidecarContainers:
Expand Down
95 changes: 95 additions & 0 deletions test/qdrant_labels_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package test

import (
v1 "k8s.io/api/core/v1"
"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"
networkingv1 "k8s.io/api/networking/v1"
)

func TestStatefulSetLabels(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{
"additionalLabels": `{"example.com/customLabel": "customValue"}`,
},
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.Labels, "example.com/customLabel")
require.Equal(t, statefulSet.Labels["example.com/customLabel"], "customValue")
}

func TestIngressLabels(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{
"ingress.enabled": `true`,
"additionalLabels": `{"example.com/customLabel": "customValue"}`,
},
KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName),
}

output := helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/ingress.yaml"})

var ingress networkingv1.Ingress
helm.UnmarshalK8SYaml(t, output, &ingress)

require.Contains(t, ingress.Labels, "example.com/customLabel")
require.Equal(t, ingress.Labels["example.com/customLabel"], "customValue")
}

func TestServiceAccountLabels(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{
"additionalLabels": `{"example.com/customLabel": "customValue"}`,
},
KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName),
}

output := helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/serviceaccount.yaml"})

var serviceAccount v1.ServiceAccount
helm.UnmarshalK8SYaml(t, output, &serviceAccount)

require.Contains(t, serviceAccount.Labels, "example.com/customLabel")
require.Equal(t, serviceAccount.Labels["example.com/customLabel"], "customValue")
}
Loading