Cost for Platforms What Drives Spend and How to Reduce It
How Kubernetes costs arise, how to attribute cloud billing to namespaces using OpenCost, and practical strategies to visualize, right size, and reduce compute, storage, and network spend
This lesson focuses on money: what drives Kubernetes costs, how to make those costs visible, and practical ways to reduce them. Everything covered earlier in the course has cost implications; this lesson gives you a framework and tools to answer who, what, and where the money is going — and what to do about it.A mid‑sized SaaS company saw its monthly Kubernetes cloud bill rise from 30,000to120,000 in a year. Finance showed a single line item: $84,000 in EC2 charges. The platform team could not map that charge to teams, namespaces, or workloads — so the CTO could not know which engineering teams or workloads were responsible or whether the usage was justified.
The practical solution is namespace-level cost allocation: attribute node, storage, and network costs to namespaces (or labels) so you can identify which teams and workloads drive spend. With that visibility you can systematically eliminate unused capacity and right‑size resources.The solution looks like this in practice: map cloud billing to Kubernetes constructs, then use that insight to right‑size and reclaim unused capacity.
What drives Kubernetes costs?Use the following prioritized categories to focus your optimization efforts. Compute is typically the largest opportunity.
Category
Typical share
Main drivers / examples
Compute
60–70%
Worker nodes: EC2/GCE/VMs, CPU and RAM provisioning (you pay for provisioned capacity, not actual usage). Right‑sizing nodes/pods reduces waste.
Storage
15–25%
Persistent volumes, SSD vs HDD pricing (SSDs are often 3–5× more expensive), snapshots and unused volumes that accumulate.
Network
10–20%
Load balancers and egress (internet/data transfer) charges — per‑GB costs can be surprisingly large.
The number‑one cost driver is provisioned capacity you do not actually use — the gap between node capacity and actual workload consumption. Many organizations see 40–60% of their provisioned compute idle. Closing that gap is the highest‑leverage optimization.Visibility is the blocker: cloud bills are organized by infrastructure resources (EC2, EBS, ELB, Data Transfer), not by teams, namespaces, or applications. That makes it impossible to answer questions like:
How much does the Payments team cost?
Which namespace is wasting the most resources?
Are we over‑provisioned or under‑provisioned?
You need a tool that understands both the cloud pricing model and Kubernetes resource constructs (pods, namespaces, labels) to bridge this gap.
That bridging tool is OpenCost — an open-source, vendor-neutral project that runs in your cluster, scrapes resource usage, applies cloud prices, and exposes dollar‑based metrics scoped to pods, namespaces, and labels.
OpenCost runs as a pod in your cluster, scrapes usage from the Kubernetes Metrics API or Prometheus (if available), and overlays that usage with cloud pricing to produce dollar-cost metrics for pods, namespaces, and labels.
OpenCost gives three core capabilities that solve the visibility problem:
Cost allocation by namespace or label — attribute node and storage costs to teams and applications so finance and engineering can see true spend per owner.
Resource efficiency metrics — show actual CPU/memory usage vs. requested resources, which is the basis for right‑sizing.
Real‑time and historical cost trends — detect spikes, regressions, and long‑term trends to prioritize remediation.
The OpenCost dashboard makes these outputs actionable: each row is a namespace (often mapping to a team), and you can filter or aggregate by label to see compute, storage, and network dollars attributed to that namespace.
Focus on the efficiency metric: percentage of requested resources that are actually used. Example interpretation:
CPU efficiency 15% = pods requested ~7× more CPU than they used → big waste.
CPU efficiency 70% = reasonable balance of cost and headroom.
CPU efficiency 240% = workload is under‑requested and may encounter throttling or instability.
How OpenCost calculates costsOpenCost follows a three‑step process:
Get cloud pricing — compute cost-per-CPU-hour and per-GB-hour for node types and storage classes.
Measure pod resource usage — collect actual CPU and memory consumption from the metrics source.
Aggregate costs — allocate node/storage costs to pods using a chosen strategy (requests, usage, or the higher of the two), then sum by namespace or labels (for example, team=Payments across multiple namespaces).
This produces actionable outputs such as “Payments costs $2,400/month,” which lets finance allocate costs to business units and platform teams prioritize right‑sizing.
OpenCost also measures efficiency as Actual Usage ÷ Requested. Here are three practical scenarios:
Over‑provisioned (low efficiency): requested 4 CPU, actual 0.5 CPU → 12.5% efficiency. Most waste lives here.
Right‑sized (target zone): requested 1 CPU, actual 0.7 CPU → 70% efficiency. Good balance of cost and headroom.
Under‑provisioned (high efficiency): requested 0.5 CPU, actual 1.2 CPU → 240% efficiency. Risk of throttling / instability.
Target range: 60–80% efficiency. Below 50% indicates substantial, recoverable waste. Above 90% leaves little headroom for spikes and increases the risk of resource contention.
How to reduce costs — a practical roadmapCost reduction is continuous and should be prioritized by dollar impact. Focus on compute first — it usually accounts for the largest share.
Horizon
Typical actions
Expected impact
Quick wins (this week)
Right-size pod requests, delete idle dev/staging environments, move batch workloads from SSD to HDD
20–40% reduction on many teams
Medium term (this month)
Use spot/preemptible instances for fault‑tolerant workloads, enable cluster and pod autoscaling
Significant ongoing savings with moderate effort
Long term (quarter+)
Adopt cost‑aware architecture, purchase reserved capacity where justified, build team accountability (budgets, alerts)
Sustainable, predictable lower unit costs and cultural change
Combine visibility with governance:
Use resource quotas and limit ranges to prevent accidental overconsumption.
Use namespace/label cost allocation to show teams their true spend.
Let teams own budgets and alerts; incentivize optimization through reporting and periodic reviews.
When visibility (OpenCost) and governance (quotas, budgets, alerts) are combined, teams can self‑optimize and cost reduction becomes part of normal engineering practice rather than an ad‑hoc project.Key takeaways
Focus on compute utilization and right‑sizing — this yields the largest, most immediate savings.
Use OpenCost (or an equivalent) for namespace‑level visibility to map cloud billing to Kubernetes usage.
Target 60–80% efficiency; < 50% is wasteful, > 90% is risky.
Combine visibility with governance (quotas, budgets, alerts) so teams can self‑manage costs.
Treat cost optimization as continuous: prioritize quick wins, deliver medium‑term improvements, and invest in long‑term cultural change.