OCPBUGS-142731: secure operator metrics on OCP #84
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.40) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 295 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.340
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #84"
general
weight: 0.35
linkvt
Karpenter Operator on standalone OCP is failing a devpreview Prometheus conformance test: https://redhat.atlassian.net/browse/OCPBUGS-142731. In particular, the test checks for HTTPS scrape targets, but currently we only serve KO metrics on OCP over HTTP.
Note that HCP is out of scope here.
First commit
The first commit of this PR allows metrics to be served over HTTPS for KO. Here are the list of relevant changes:
1. A new argument
--metrics-cert-dirto the karpenter-operator binary which specifies a directory containing tls.crt and tls.key for the internal metrics server to serve HTTPS. Setting this argument also enables token authentication and authorization for metrics scrapes.2. A new Service is created in the install directory for CVO to apply, which targets the KO Deployment and exposes its named metrics container port on the Service at port 8080.
- We annotate this Service with
service.beta.openshift.io/serving-cert-secret-name: karpenter-operator-certwhich tells the service-ca controller to create and maintain a serving certificate for the Service in the form of a Secret containing a TLS cert and private key.- We mount that Secret to KO, and allow the internal metrics server to be instantiated using that cert and key.
- This allows clients like Prometheus to verify that the HTTPS connection is trustworthy by checking that the cert matches the Service’s DNS name and was signed by a trusted service CA.
3. We add unit tests for the metrics server configuration and update the e2e metrics test to verify HTTPS with certificate validation and token authentication. Also adds a test that specifically verifies that Prometheus in-cluster discovers the KO target and successfully scrapes it over HTTPS.
- There is new RBAC to allow the Prometheus service account to discover the karpenter-operator metrics endpoints. KO also gets
TokenReviewandSubjectAccessReviewpermissions to authenticate and authorize incoming scrapes.- We also replace the pre-existing
PodMonitorwith a newServiceMonitorwhich targets the new Service.Second commit
The second commit adds a small change which allows the karpenter_operator_info metric to be initialized even if we are on an unsupported platform.
Third commit
The third commit excludes the gocyclo check from being enforced in _test.go files.