mirror of
https://github.com/outbackdingo/qdrant-helm.git
synced 2026-01-27 10:20:18 +00:00
Make ingressClassName configurable (#86)
* Make ingressClassName configurable Fixes https://github.com/qdrant/qdrant-helm/issues/84 * Fix CI * Fix CI * Fix CI
This commit is contained in:
4
Makefile
4
Makefile
@@ -6,3 +6,7 @@ test-unit:
|
||||
|
||||
test-integration:
|
||||
bats test/integration --verbose-run --show-output-of-passing-tests
|
||||
|
||||
test-unit-lint:
|
||||
gofmt -w -s ./test
|
||||
golangci-lint run ./test
|
||||
@@ -13,6 +13,9 @@ metadata:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if .Values.ingress.ingressClassName }}
|
||||
ingressClassName: {{ .Values.ingress.ingressClassName }}
|
||||
{{- end }}
|
||||
{{- with .Values.ingress.hosts }}
|
||||
rules:
|
||||
{{- range . }}
|
||||
|
||||
@@ -39,6 +39,7 @@ service:
|
||||
|
||||
ingress:
|
||||
enabled: false
|
||||
ingressClassName: ""
|
||||
additionalLabels: {}
|
||||
annotations: {}
|
||||
# kubernetes.io/ingress.class: alb
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"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 TestPvcAnnotations(t *testing.T) {
|
||||
@@ -38,3 +39,30 @@ func TestPvcAnnotations(t *testing.T) {
|
||||
require.Contains(t, statefulSet.Spec.VolumeClaimTemplates[0].ObjectMeta.Annotations, "test")
|
||||
require.Equal(t, statefulSet.Spec.VolumeClaimTemplates[0].ObjectMeta.Annotations["test"], "value")
|
||||
}
|
||||
|
||||
func TestIngressAnnotations(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`,
|
||||
"ingress.annotations": `{"test": "value"}`,
|
||||
},
|
||||
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.ObjectMeta.Annotations, "test")
|
||||
require.Equal(t, ingress.ObjectMeta.Annotations["test"], "value")
|
||||
}
|
||||
|
||||
71
test/qdrant_ingress_test.go
Normal file
71
test/qdrant_ingress_test.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"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"
|
||||
networkingv1 "k8s.io/api/networking/v1"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestIngressWithIngressClassName(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`,
|
||||
"ingress.ingressClassName": `"nginx"`,
|
||||
},
|
||||
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.Equal(t, "nginx", *ingress.Spec.IngressClassName)
|
||||
}
|
||||
|
||||
func TestIngressWithTls(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`,
|
||||
"ingress.hosts": `[{"host":"test.qdrant.local","paths":[{"path":"/","pathType":"Prefix","servicePort": 6333}]}]`,
|
||||
"ingress.tls": `[{"hosts":["test.qdrant.local"],"secretName":"test-secret"}]`,
|
||||
},
|
||||
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.Equal(t, "test.qdrant.local", ingress.Spec.Rules[0].Host)
|
||||
require.Equal(t, "/", ingress.Spec.Rules[0].HTTP.Paths[0].Path)
|
||||
require.Equal(t, networkingv1.PathType("Prefix"), *ingress.Spec.Rules[0].HTTP.Paths[0].PathType)
|
||||
require.Equal(t, int32(6333), ingress.Spec.Rules[0].HTTP.Paths[0].Backend.Service.Port.Number)
|
||||
require.Equal(t, "test.qdrant.local", ingress.Spec.TLS[0].Hosts[0])
|
||||
require.Equal(t, "test-secret", ingress.Spec.TLS[0].SecretName)
|
||||
}
|
||||
Reference in New Issue
Block a user