123DevOps··8 min read

What is OpenCost? Kubernetes cost allocation by namespace, workload, and label

Learn what OpenCost is, how it calculates the cost of each workload and the cluster's idle cost, how it integrates with cloud pricing and bills, and how it relates to Kubecost and the FOCUS standard.

Kubernetes

Your cloud bill shows what you spent on instances, disks, and load balancers. It doesn’t show that half of a node was reserved for the payments team, that the test namespace never gets shut down, or that a third of the cluster is paid for and idle. On Kubernetes, many teams share the same machines, and the question “how much does this service cost?” has no answer on the bill. OpenCost fills that gap.

What OpenCost is

OpenCost is a vendor-neutral open source project for measuring and allocating cloud infrastructure and container costs, with a focus on Kubernetes. It was created by Kubecost, joined the CNCF as a Sandbox project in June 2022, and moved to Incubating in October 2024 — the level it holds as of November 2026 (check the project page). It is licensed under Apache 2.0.

The project has two parts:

  • The OpenCost specification: a document that defines, in a neutral way, how to calculate the total cost of a cluster, the cost of each workload, and the idle cost.
  • The implementation: a service that reads cluster metrics, combines them with prices, and exposes the result through an API, a web UI, and a CLI.

The project ships releases often; on the GitHub releases page, the most recent one we saw was v1.121.4.

What problem it solves

  • Showback and chargeback: showing (or billing) each team the cost of its namespaces and workloads.
  • Visible idle cost: separating what is paid for and allocated from what is paid for and unused.
  • A basis for unit economics: without the cost of each service, you can’t calculate cost per transaction or per customer.
  • Neutrality: the same methodology across AWS, Azure, GCP, other clouds, and on-premises, instead of a different tool per provider.

How it works

Component Role
opencost service (port 9003) Calculates allocations and exposes the API (/allocation, /cloudCost)
Web UI (port 9090) Shows costs by namespace, controller, label, and other dimensions
Prometheus Required by the default installation: collects and stores usage metrics
Cloud pricing The provider’s public on-demand price lists; spot and custom prices when configured
Cloud Costs Optional integration with the actual bill from AWS, Azure, GCP, OCI, and others
kubectl cost Command-line plugin that queries the API

Recent versions also ship an optional MCP server, disabled by default.

The math behind each workload

The specification separates asset costs (nodes, disks, load balancers, traffic) from workload costs. For CPU, memory, and GPU, each container is charged for the greater of what it requested (request) and what it used, multiplied by time and by the resource’s hourly price on that node. The logic is simple: what you reserved was unavailable to everyone else, even if you didn’t use it. Volumes are charged by PVC size.

From the container up, costs are aggregated by pod, controller (Deployment, StatefulSet…), namespace, label, annotation, node, or cluster. Good requests stop being just a scheduling concern: they become the basis of the bill — see Kubernetes scheduling and resources.

Idle cost

Per the specification, idle cost = cluster asset cost − workload cost: the part of the paid capacity that no workload reserved. The API can show it as an __idle__ line (includeIdle), spread it proportionally across workloads (shareIdle), and compute it per node instead of per cluster (idleByNode). High idle cost usually points to oversized nodes, poor bin packing, or reserved capacity nobody uses.

Pricing and cloud integrations

By default, OpenCost uses the provider’s public on-demand prices for each node’s region — on AWS, for example, the public EC2 price index, with no extra configuration. From there, you have three possible refinements:

  • Spot: on AWS, by reading the Spot Instance Data Feed from an S3 bucket.
  • Custom pricing: your own values in the Helm values, useful for on-premises or negotiated contracts.
  • Cloud Costs: reading the actual bill (on AWS, the Cost and Usage Report, including CUR 2.0, via Athena), configured in a cloud-integration.json stored in a Secret. Data shows up with the bill’s own delay, from hours up to a day.

Watch out: the documentation says on-demand prices are not reconciled against the bill. Commitment discounts show up in the Cloud Costs view, not automatically in each pod’s cost.

OpenCost, Kubecost, and FOCUS

Kubecost is the commercial product built on OpenCost, with additional features and support; the company was acquired by IBM in 2024. OpenCost remains a CNCF project with its own governance. If you only need allocation and visibility, OpenCost is usually enough; commercial editions make sense when you want extra features and support.

FOCUS is a different layer: a FinOps Foundation standard for the format of cloud bills, explained in FOCUS: the open billing standard. It standardizes the bill’s line items, but it doesn’t split a node across namespaces. OpenCost does that split inside the cluster and, since 2023, has been aligning its terminology with FOCUS. The two complement each other: FOCUS for the bill, OpenCost for Kubernetes allocation. Check the documentation for which FOCUS version your OpenCost version supports.

Hands-on example

Install with Helm, pointing to a Prometheus that already runs in the cluster:

# values-opencost.yaml
opencost:
  prometheus:
    internal:
      namespaceName: monitoring
      serviceName: prometheus-kube-prometheus-prometheus
      port: 9090
helm repo add opencost-charts https://opencost.github.io/opencost-helm-chart
helm install opencost opencost-charts/opencost \
  --namespace opencost --create-namespace -f values-opencost.yaml

# API on 9003 and UI at http://localhost:9090
kubectl -n opencost port-forward deployment/opencost 9003 9090

With the port-forward running, the API answers questions like these:

# Cost per namespace over the last 7 days
curl -s "http://localhost:9003/allocation?window=7d&aggregate=namespace"

# Daily cost this month by namespace and by the team label, with the idle line
curl -s "http://localhost:9003/allocation?window=month&aggregate=namespace,label:team&step=1d&includeIdle=true"

# Idle spread across workloads and calculated per node
curl -s "http://localhost:9003/allocation?window=today&aggregate=controller&shareIdle=true&idleByNode=true"

And the same from the CLI, with the kubectl cost plugin (commands as documented upstream):

kubectl krew install cost
kubectl cost --service-port 9003 --service-name opencost --kubecost-namespace opencost \
  --allocation-path /allocation/compute \
  namespace --historical --window 7d --show-cpu --show-memory

The output looks like this (values intentionally omitted):

NAMESPACE      CPU        MEMORY     TOTAL
payments       <cost>     <cost>     <cost>
checkout       <cost>     <cost>     <cost>
__idle__       <cost>     <cost>     <cost>

To turn this into a business metric, divide the namespace cost by the transaction volume for the same period, as in unit economics: cost per transaction.

When to use it (and when not to)

It makes sense when:

  • Several teams or products share clusters and you need showback or chargeback.
  • You want to see idle cost and the waste from oversized requests.
  • Your environment is multicloud or on-premises and you want a single methodology.
  • Prometheus already runs in the cluster, or you are willing to operate it.

Think twice when:

  • There is a single team and a single cluster: the bill plus tags may be enough.
  • You need budgets, advanced alerting, and commercial support out of the box: evaluate commercial editions or FinOps platforms.
  • Nobody will act on the numbers. A cost dashboard without an owner doesn’t cut costs; the practices in FinOps: cutting AWS costs start with clear ownership.

Alternatives

Option What it is When to consider it
OpenCost CNCF project, open specification, and implementation Neutral, multicloud allocation with no license cost
Kubecost (IBM) Commercial product built on OpenCost Extra features and commercial support
Provider tools Kubernetes cost allocation offered by AWS, Google Cloud, and Azure A single provider and a preference for a managed service
FinOps platforms Tools that consolidate bills (many in FOCUS) A company-wide financial view beyond Kubernetes

Summary

  • OpenCost is a CNCF Incubating project (as of November 2026) for allocating Kubernetes and cloud costs
  • Workloads are charged for the greater of request and usage, times duration and the resource’s price
  • Idle cost is asset cost minus workload cost; use includeIdle, shareIdle, and idleByNode
  • Public on-demand prices are the default; spot, custom pricing, and Cloud Costs refine the numbers
  • Kubecost is the commercial product built on OpenCost
  • FOCUS standardizes the bill; OpenCost splits the cluster by namespace, workload, and label
  • Numbers only cut costs when every namespace has an owner

OpenCost doesn’t shrink the bill on its own — it shows who each part of it should be sent to.

Get updates on new posts and stay in the loop!