Skip to main content
This lesson explains the financial side of running Kubernetes: what causes cloud spend, how to make that spend visible, and how to reduce it systematically. By the end you’ll have a practical framework and tools to answer: Where is our cloud spend going? Who is spending it? And what can we do to reduce it?
The image outlines five learning objectives related to Kubernetes cost management, including identifying cost drivers, using OpenCost, analyzing spending, implementing cost optimization, and understanding cost management.

What actually drives Kubernetes costs?

Consider this real example: a mid-sized SaaS provider saw its monthly Kubernetes cloud bill jump from 30,000to30,000 to 120,000 in a year. The cloud invoice showed a large EC2 line item, but the platform team couldn’t map those dollars to namespaces, teams, or workloads — so they couldn’t tell whether the spend was justified or wasteful.
The image highlights a problem labeled "Cloud Bill Surprise," with subpoints on "Unplanned Scaling" and "K8s Infrastructure."
The image presents a problem statement regarding resource consumption by engineering teams, highlighting questions about which teams and workloads were responsible and whether the usage was justified or wasteful, with a total EC2 cost of $84,000.
The operational solution is to introduce namespace-level cost allocation so teams and finance can map cloud dollars to platform constructs. With that visibility you can systematically eliminate unused capacity and right-size resources where it matters most.
The image outlines a solution involving namespace-level cost allocation to identify spending, and using insights to optimize resources and eliminate unused capacity.

Major cost categories (and where to focus)

Kubernetes cloud spend generally falls into three primary categories. Prioritize efforts where dollars are concentrated to get the highest ROI.
The image outlines the factors driving Kubernetes costs, categorized into Compute (60-70% of total spend), Storage (15-25% of total spend), and Network (10-20% of total spend), detailing specific cost contributors for each category.
The single largest cost driver is provisioned capacity you do not actually use — the gap between what you pay for (node capacity) and what workloads consume. In many organizations that utilization gap represents 40–60% waste. Closing that gap is the highest-leverage optimization.
The image illustrates the cost drivers of Kubernetes, highlighting the gap between paid node capacity and actual workload consumption, with an emphasis on reducing the utilization gap to optimize costs.

The visibility gap: cloud bill vs platform usage

The cloud bill shows dollars by account, service, and line item — not by namespace, team, or workload. That mismatch is the visibility gap: finance sees charges, platform engineers see Kubernetes constructs, and neither can easily attribute dollars to business units. Typical questions to answer: Bridging this gap requires a tool that understands cloud pricing and Kubernetes resource models. OpenCost is one such open-source solution.
The image illustrates a "visibility problem" between cloud billing at the infrastructure level and Kubernetes usage at the platform level, highlighting OpenCost as a bridging solution.
OpenCost is an open-source, vendor-neutral project (CNCF incubating) that maps Kubernetes usage to cloud pricing so you can attribute dollars to namespaces, labels, and pods.

OpenCost overview: how it works and what it provides

OpenCost runs inside Kubernetes as a set of pods. It scrapes usage from the Kubernetes Metrics API or Prometheus, overlays cloud pricing, and produces dollar-based allocations.
The image is a slide titled "OpenCost: Kubernetes Cost Visibility," highlighting OpenCost as an open-source, vendor-neutral, CNCF incubating project.
The image illustrates "OpenCost: Kubernetes Cost Visibility," showing a Kubernetes Cluster with an OpenCost Pod, alongside Metrics API and Pricing data components detailing per-hour node costs, per-GB storage costs, and data transfer costs.
What OpenCost gives you (three core capabilities):
  1. Cost allocation by namespace or label
    • Attributes node, storage, and network costs to namespaces/labels according to pod consumption. Example: if a node costs 1,000/monthandateamspodsconsume101,000/month and a team's pods consume 10% of that node, the team is allocated 100/month.
  2. Resource-efficiency metrics
    • Shows CPU/memory utilization vs requests so you can surface over-provisioned (waste) and under-provisioned (risk) workloads.
  3. Real-time and historical data
    • Time-series cost trends and anomaly detection (e.g., sudden spikes or month-over-month growth).
The image shows a dashboard of OpenCost displaying Kubernetes cost visibility, with a cost allocation chart for the last 7 days by namespace, indicating zero cost for various resources.

How OpenCost calculates costs

OpenCost follows a simple three-step model to turn metrics into dollars:
  1. Get cloud pricing
    • Derive per-CPU-hour and per-GB-hour node costs (and storage/network rates) using cloud provider pricing.
  2. Measure pod resource usage
    • Collect actual CPU/memory usage. OpenCost charges the higher of the pod’s request or its actual usage so both waste and risk are visible.
  3. Aggregate by namespace or label
    • Sum pod-level costs into namespace/label totals (for example, all pods labeled team=payments).
The result is a concrete allocation such as: the Payments namespace costs $2,400/month — which closes the visibility gap and enables finance and engineering to act.
The image illustrates cost allocation by namespace, highlighting a monthly expense of $2,400 for the "team-payments" namespace, with roles for Finance in allocating cloud costs and Engineering Leadership in identifying costly workloads.

Efficiency metric and the target zone

OpenCost computes efficiency as actual usage divided by requests. Interpretations:
  • Over-provisioned: Low efficiency (e.g., 12.5%). Large waste — you’re paying for far more than you need.
  • Right-sized: Efficiency ~60–80% — the recommended target zone balancing cost and headroom for spikes.
  • Under-provisioned: Efficiency >100% (e.g., 240%) — the pod is using more than requested and may cause throttling or OOM kills.
Aim for the 60–80% band. Below 50% indicates significant waste; above 90% suggests little headroom and higher operational risk. The right-sizing workflow looks like: profile usage, set requests near the 95th percentile, and target the 60–80% efficiency band.
The image compares three scenarios of CPU usage efficiency: over-provisioned with low efficiency, right-sized with balanced efficiency, and under-provisioned with high efficiency but potential risks.
The image is a cost-efficiency spectrum comparing requested versus used efficiency, categorized into zones: "Wasted Money" (below 50%), "Target Zone" (60-80%), and "High Risk" (90%+), with the tool OpenCost used to show namespace placement on this spectrum.
Be careful when right-sizing: aggressive reductions can cause production outages. Always validate changes in a staging or canary environment and combine metrics with business context.

How to reduce costs — an operational roadmap

Cost reduction is continuous. Organize efforts across short, medium, and long horizons and prioritize by dollar impact (start with compute/node costs).
The image outlines cost reduction strategies categorized into quick wins, medium-term, and long-term approaches, each with specific tactics for optimizing resources and saving costs.
Prioritize your top-dollar namespaces first (e.g., the ten costliest). Often, the biggest ROI comes from right-sizing those namespaces and removing idle nodes.

Combine visibility with governance

Visibility plus governance creates sustainable cost control:
  • Visibility (OpenCost): maps dollars to teams and workloads.
  • Governance: quotas, limits, and automated policies prevent runaway consumption.
  • Culture: show teams their costs and give them the tools to self-optimize.
When combined, these elements enable continuous cost optimization instead of reactive firefighting. This concludes the module covering architecture, resources, multi-tenancy, governance, storage, networking, and cost.

Watch Video