← Back to Pull requests

OCPBUGS-142731: secure operator metrics on OCP #84

Closed
unknown closed this pull request without merging on Nov 27, 2026 16:32 UTC
View on GitHub
unknown unknown commented on Nov 24, 2026 03:45 UTC
Author

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-dir to 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-cert which 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 TokenReview and SubjectAccessReview permissions to authenticate and authorize incoming scrapes.
- We also replace the pre-existing PodMonitor with a new ServiceMonitor which 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.

Diff: 295 lines (+221 / -74) across 3 files Reviewer: linkvt Review duration: 5087m
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
0.40
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
56%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 56.8% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 40.0% (MEDIUM) · Higher = larger blast radius
40.0%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 56.8% · Lower = rushed or shallow review
56.8%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 17.3% · Safe to merge
17.3%