Add cost views and workload rightsizing#1101
Open
nadaverell wants to merge 32 commits into
Open
Conversation
9fe6e3c to
9cf2aa5
Compare
5654415 to
7f7f6fc
Compare
# Conflicts: # packages/k8s-ui/src/components/applications/ApplicationDetail.test.tsx # packages/k8s-ui/src/components/applications/ApplicationDetail.tsx # packages/k8s-ui/src/components/workload/WorkloadView.tsx # web/src/components/applications/ApplicationsView.tsx
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ae29b5c. Configure here.
| unique = append(unique, prom.EscapeRegexMeta(value)) | ||
| prev = value | ||
| } | ||
| return strings.Join(unique, "|") |
There was a problem hiding this comment.
Unsafe workload names in trends
Medium Severity
Application cost trend queries build owner_name=~ alternations with EscapeRegexMeta only, unlike rightsizing scan helpers that also run SanitizeLabelValue. Workload names containing PromQL-special characters can break or skew trend queries.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit ae29b5c. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Adds OpenCost-backed cost visibility for clusters, applications, and workloads, plus an on-demand Rightsizing view for finding CPU and memory requests worth reviewing.
Rightsizing methodology
Rightsizing is advisory evidence, not an efficiency grade, automatic YAML change, capacity plan, or guaranteed savings estimate.
The fleet scan runs only when the user starts it. Queries are concurrency-bounded and use exact kube-state-metrics ownership; workload detail can fall back to exact current pods when historical ownership is unavailable.
Cost behavior
Scope
Batch/job cost, storage/PVC attribution, network attribution, VPA integration, and automatic request changes remain out of scope. Capacity reductions are requested resources across replicas, not guaranteed reductions in the cloud bill.
Validation
make tscmake testmake buildgit diff --check/Users/nadaverell/workspace/sky/ws10/radar/.playwright-mcp/visual-test/20260713-rightsizing-conservative/Note
Medium Risk
Large new surface area (Prometheus-heavy rightsizing math, batched scans, OpenCost RBAC APIs) with behavior changes on discovery failures; mistakes could mis-rank recommendations or mis-report cost, but changes are mostly additive behind new routes and optional UI tabs.
Overview
Introduces OpenCost-backed cost at cluster-adjacent APIs and in the UI: optional Cost tabs on applications and workloads (Deployments/StatefulSets/DaemonSets), plus server routes for application and per-workload current cost and trends with RBAC preflight, partial coverage, and scaled-to-zero handling.
Rightsizing is rebuilt around a 7-day Prometheus window: rightsizing classification (balanced/oversized/under-requested, etc.), confidence and sample coverage, HPA/OOM/throttle signals, and conservative staged reduction rules. A new fleet scan (
POST /prometheus/rightsizing/scan) batches workloads (50 at a time) with kube-state-metrics ownership vectors and namespace-scoped RBAC.Prometheus client changes improve reliability: serialized discovery, a short TTL cache for repeated discovery failures,
ErrPrometheusNotFoundfor empty discovery, and preserving cached connections when probes fail due to context cancellation. OpenCost handlers map connection errors toReasonNoPrometheusvsReasonQueryError, and node cost responses can includeProviderIDfrom the node informer.pkg/opencost adds application cost/trend aggregation and hardens Prom queries (deduped node/PV series, shared cost expr helpers). UI adds
SelectMenuand workload/application hooks for host-rendered cost bodies.Reviewed by Cursor Bugbot for commit ae29b5c. Bugbot is set up for automated code reviews on this repo. Configure here.