mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-02 21:30:46 +09:00
fix(qdrant): scrape TLS metrics over HTTPS (#5340)
## What this PR does
Qdrant with TLS enabled serves metrics over HTTPS, but its
ServiceMonitor still uses HTTP. Patch the rendered endpoint to use HTTPS
with the issued CA and a certificate SAN. The API key and explicit TLS
opt-out are preserved.
Validation: 3 regression tests and 110 Helm tests pass; both TLS cases
fail without the patch. The full Bats run has 183 failures on this macOS
host, all reproduced on unchanged main. The POSIX lane has 4 baseline
failures as well.
### Downstream repositories
- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:
### Release note
```release-note
fix(qdrant): restore metrics scraping for TLS-enabled instances by using HTTPS and verifying the server certificate against the issued CA.
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **New Features**
* Qdrant monitoring now uses HTTPS when TLS is enabled, with certificate
verification and the configured server name.
* Monitoring connections use the release’s TLS certificate authority,
while non-TLS setups continue to use HTTP.
* External Qdrant monitoring uses HTTPS by default.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Backported-from: f5479e7093
This commit is contained in:
commit
72ca3aaf46
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