Add TLS support to Prometheus metrics server#3322
Add TLS support to Prometheus metrics server#3322jkhelil wants to merge 1 commit intoknative:mainfrom
Conversation
|
@jkhelil: The label(s) DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Hi @jkhelil. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: jkhelil The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3322 +/- ##
==========================================
+ Coverage 74.61% 74.66% +0.04%
==========================================
Files 188 188
Lines 8215 8237 +22
==========================================
+ Hits 6130 6150 +20
- Misses 1844 1846 +2
Partials 241 241 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Add WithTLSConfig() and WithTLSCertFiles() server options
- Support METRICS_TLS_CERT and METRICS_TLS_KEY env vars
5492d68 to
545d035
Compare
This PR adds native TLS/HTTPS support to the Prometheus metrics server in
knative.dev/pkg/observability/metrics/prometheus, enabling secure metrics collection without requiring additional sidecars or proxies.Problem
Many production environments require encrypted metrics endpoints for compliance and security, but the current Prometheus server only supports plain HTTP. Existing solutions have significant drawbacks:
kube-rbac-proxy limitations:
Post-Quantum Cryptography (PQC) Readiness:
Solution
Native TLS support in the Prometheus server provides:
Changes
observability/metrics/prometheus/server.go(+71, -8 lines)crypto/tlsimportMETRICS_TLS_CERTandMETRICS_TLS_KEYconstantsServerstruct withcertFile,keyFilefieldsoptionsstruct withtlsConfig,certFile,keyFileListenAndServe()to return error and implement TLS priority logicWithTLSConfig()andWithTLSCertFiles()server optionsContextWithTLSConfig()andTLSConfigFromContext()context helpersobservability/metrics/prometheus/server_test.go(+118 lines)WithTLSConfig()optionWithTLSCertFiles()optionobservability/metrics/prometheus_enabled.go(+11, -2 lines)buildPrometheus()to usectx context.Context(not_)TLSConfigfrom context if presentListenAndServe()/kind enhancement
Fixes #
Release Note
Docs