feat(k8s): Phase 4 — workload cost attribution + health audit#152
Merged
Conversation
added 2 commits
April 29, 2026 14:54
Estimate Kubernetes spend by attributing each pod's share of its host
node's hourly price. Pod share = max(cpu_request / node_alloc_cpu,
mem_request / node_alloc_mem); pod cost = node_hourly * share. This is
the standard Kubecost-style model.
• new internal/k8s/cost package — WorkloadCostAttributor with
aggregations by pod, workload, namespace, and node
• static AWS on-demand price fallback (m5/c5/r5/t3 + i variants);
operators with real billing data plug in via --prices <file> and
fall back to the static table on misses (CompositePriceLookup)
• CPU/memory quantity parsers cover all standard k8s suffixes
(m, Ki/Mi/Gi, k/M/G, plain bytes)
• ReplicaSet pods unwrap to their parent Deployment by stripping the
podtemplate hash; Job pods named with a trailing unix-ts unwrap to
CronJob; orphan pods report kind=Pod
• clanker k8s cost subcommand: --by pod|workload|namespace|node,
--prices override, --top N, JSON output
Read-only — only kubectl get is invoked. Tests cover happy path,
error propagation, divide-by-zero on broken nodes, owner-ref unwrap
edge cases, and provider detection.
One-shot "what's broken in this cluster" report. Wraps the existing DiagnosticsManager.DetectClusterIssues and classifies each issue into reliability categories so operators see a count first, the long flat issue list second. Categories: • CrashLoopBackOff • OOMKilled (matches both "OOMKilled" and "OOM killed" wordings) • ImagePullBackOff / ErrImagePull • RestartSpike (≥5 restarts) • NotReady • NodePressure (Memory/Disk/PID/NetworkUnavailable) • Other Output also surfaces "Hot pods" — the top 25 pods with the most issues, flagged with their categories so operators know where to look first. Read-only — only kubectl get is invoked. Tests cover the healthy-cluster empty case, classification across all categories, and the HotPods top-N trim.
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
Phase 4 ships the two largest remaining K8s gaps from the Tier-2 backlog:
Commits
Test plan