feat: add support for volumeAttributesClass for pvcs (#396)

closes #365
This commit is contained in:
Robert Marsal
2025-10-22 14:56:46 +01:00
committed by GitHub
parent ddeb35a9fa
commit 99de33f615
3 changed files with 43 additions and 3 deletions

View File

@@ -266,6 +266,9 @@ spec:
{{- end }}
spec:
storageClassName: {{ .Values.persistence.storageClassName }}
{{- if .Values.persistence.volumeAttributesClassName }}
volumeAttributesClassName: {{ .Values.persistence.volumeAttributesClassName }}
{{- end }}
accessModes:
{{- range .Values.persistence.accessModes }}
- {{ . | quote }}
@@ -284,6 +287,9 @@ spec:
{{- end }}
spec:
storageClassName: {{ .Values.snapshotPersistence.storageClassName }}
{{- if .Values.snapshotPersistence.volumeAttributesClassName }}
volumeAttributesClassName: {{ .Values.snapshotPersistence.volumeAttributesClassName }}
{{- end }}
accessModes:
{{- range .Values.snapshotPersistence.accessModes }}
- {{ . | quote }}

View File

@@ -148,6 +148,7 @@ persistence:
# storageVolumeName: qdrant-storage
# storageSubPath: ""
# storageClassName: local-path
# volumeAttributesClassName: ""
# If you use snapshots or the snapshot shard transfer mechanism, we recommend
# creating a separate volume of the same size as your main volume so that your
@@ -161,6 +162,7 @@ snapshotPersistence:
# snapshotsSubPath: ""
# You can change the storageClassName to ensure snapshots are saved to cold storage.
# storageClassName: local-path
# volumeAttributesClassName: ""
snapshotRestoration:
enabled: false

View File

@@ -1,15 +1,16 @@
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"
"path/filepath"
"strings"
"testing"
)
func TestContainerSecurityContextUserAndGroupDefault(t *testing.T) {
@@ -69,3 +70,34 @@ func TestContainerSecurityContextUserAndGroupLargeValues(t *testing.T) {
require.Equal(t, int64(1000740000), *statefulSet.Spec.Template.Spec.SecurityContext.FSGroup)
require.Equal(t, int64(1000840000), *statefulSet.Spec.Template.Spec.Containers[0].SecurityContext.RunAsGroup)
}
func TestCanAttachVolumeAttributesClassToPersistence(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": `{
"volumeAttributesClassName": "my-class"
}`,
"snapshotPersistence": `{
"enabled": true,
"volumeAttributesClassName": "my-class"
}`,
},
KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName),
}
statefulsetOutput := helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/statefulset.yaml"})
var statefulSet appsv1.StatefulSet
helm.UnmarshalK8SYaml(t, statefulsetOutput, &statefulSet)
require.Equal(t, "my-class", *statefulSet.Spec.VolumeClaimTemplates[0].Spec.VolumeAttributesClassName)
require.Equal(t, "my-class", *statefulSet.Spec.VolumeClaimTemplates[1].Spec.VolumeAttributesClassName)
}