mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
fix(qdrant): scrape TLS metrics over HTTPS
TLS-enabled Qdrant rejects the ServiceMonitor's HTTP requests. The
vendored chart exposes no scheme or CA value, so patch its endpoint
through the existing HelmRelease post-renderer mechanism. Trust the
issued CA and use a certificate SAN without disabling verification.
Tested the app-to-system chart render through Kustomize for explicit
TLS, external default TLS and explicit opt-out; the TLS cases fail
without the patch.
Fixes: cdb03a9929 ("feat(qdrant): implement TLS in Helm templates")
Assisted-by: LLM
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
This commit is contained in:
1 parent
060686cbc0
commit
d009a1e737
2 files changed
+71
No files matched your search
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
|
||||
setup() {
|
||||
strict_setup
|
||||
REPO_ROOT="$(cd "$BATS_TEST_DIRNAME/.." && pwd)"
|
||||
export KUBECONFIG=/dev/null
|
||||
}
|
||||
|
||||
render_monitor() {
|
||||
helm template test-qdrant "$REPO_ROOT/packages/apps/qdrant" \
|
||||
--namespace tenant-test --set _namespace.host=tenant.example.test "$@" > "$BATS_TEST_TMPDIR/app.yaml"
|
||||
yq 'select(.kind == "HelmRelease") | .spec.values' "$BATS_TEST_TMPDIR/app.yaml" > "$BATS_TEST_TMPDIR/values.yaml"
|
||||
helm template test-qdrant-system "$REPO_ROOT/packages/system/qdrant" \
|
||||
--namespace tenant-test --values "$BATS_TEST_TMPDIR/values.yaml" > "$BATS_TEST_TMPDIR/system.yaml"
|
||||
yq 'select(.kind == "HelmRelease") | {
|
||||
"apiVersion": "kustomize.config.k8s.io/v1beta1",
|
||||
"kind": "Kustomization",
|
||||
"resources": ["system.yaml"],
|
||||
"patches": (.spec.postRenderers[0].kustomize.patches // [])
|
||||
}' "$BATS_TEST_TMPDIR/app.yaml" > "$BATS_TEST_TMPDIR/kustomization.yaml"
|
||||
kubectl kustomize "$BATS_TEST_TMPDIR" > "$BATS_TEST_TMPDIR/rendered.yaml"
|
||||
yq 'select(.kind == "ServiceMonitor") | .spec.endpoints[0]' "$BATS_TEST_TMPDIR/rendered.yaml" > "$BATS_TEST_TMPDIR/endpoint.yaml"
|
||||
[ "$(yq '.authorization.credentials.name' "$BATS_TEST_TMPDIR/endpoint.yaml")" = test-qdrant-apikey ]
|
||||
[ "$(yq '.authorization.credentials.key' "$BATS_TEST_TMPDIR/endpoint.yaml")" = api-key ]
|
||||
[ "$(yq '.port' "$BATS_TEST_TMPDIR/endpoint.yaml")" = http ]
|
||||
}
|
||||
|
||||
@test "TLS monitoring uses the issued CA and a certificate SAN" {
|
||||
render_monitor --set tls.enabled=true --set _cluster.cluster-domain=cluster.test
|
||||
[ "$(yq '.scheme' "$BATS_TEST_TMPDIR/endpoint.yaml")" = https ]
|
||||
[ "$(yq '.tlsConfig.ca.secret.name' "$BATS_TEST_TMPDIR/endpoint.yaml")" = test-qdrant-tls ]
|
||||
[ "$(yq '.tlsConfig.ca.secret.key' "$BATS_TEST_TMPDIR/endpoint.yaml")" = ca.crt ]
|
||||
[ "$(yq '.tlsConfig.insecureSkipVerify // false' "$BATS_TEST_TMPDIR/endpoint.yaml")" = false ]
|
||||
server_name="$(yq '.tlsConfig.serverName' "$BATS_TEST_TMPDIR/endpoint.yaml")"
|
||||
SERVER_NAME="$server_name" yq --exit-status 'select(.kind == "Certificate" and .metadata.name == "test-qdrant-tls") | .spec.dnsNames | contains([strenv(SERVER_NAME)])' "$BATS_TEST_TMPDIR/app.yaml"
|
||||
}
|
||||
|
||||
@test "external Qdrant enables HTTPS monitoring by default" {
|
||||
render_monitor --set external=true
|
||||
[ "$(yq '.scheme' "$BATS_TEST_TMPDIR/endpoint.yaml")" = https ]
|
||||
}
|
||||
|
||||
@test "disabled TLS keeps HTTP monitoring without TLS configuration" {
|
||||
render_monitor --set external=true --set tls.enabled=false
|
||||
[ "$(yq '.scheme' "$BATS_TEST_TMPDIR/endpoint.yaml")" = http ]
|
||||
[ "$(yq 'has("tlsConfig")' "$BATS_TEST_TMPDIR/endpoint.yaml")" = false ]
|
||||
}
|
||||
@@ -18,6 +18,28 @@ spec:
|
||||
upgrade:
|
||||
remediation:
|
||||
retries: -1
|
||||
{{- if $tlsEnabled }}
|
||||
postRenderers:
|
||||
- kustomize:
|
||||
patches:
|
||||
- target:
|
||||
group: monitoring.coreos.com
|
||||
version: v1
|
||||
kind: ServiceMonitor
|
||||
name: {{ .Release.Name }}
|
||||
patch: |
|
||||
- op: replace
|
||||
path: /spec/endpoints/0/scheme
|
||||
value: https
|
||||
- op: add
|
||||
path: /spec/endpoints/0/tlsConfig
|
||||
value:
|
||||
ca:
|
||||
secret:
|
||||
name: {{ .Release.Name }}-tls
|
||||
key: ca.crt
|
||||
serverName: {{ .Release.Name }}.{{ .Release.Namespace }}.svc
|
||||
{{- end }}
|
||||
valuesFrom:
|
||||
- kind: Secret
|
||||
name: cozystack-values
|
||||
|
||||
Reference in new issue
Block a user