What is showback, and why start there instead of chargeback?

Showback reports what each team's workloads cost without moving any money. Chargeback goes further: the allocated cost is billed against a team's budget or cost center. Both depend on the same allocation data. The difference is what the organization does with the number.

Showback Chargeback
Money moves between budgets No Yes
Finance integration required No Yes, usually cost-center mapping and approval
Tolerance for allocation errors Moderate. Errors get corrected in the next report. Low. Errors become billing disputes.
Main outcome Visibility and ownership Budget enforcement

Start with showback because your first allocation model will be wrong in places. Some workloads will be unlabeled. Idle capacity will land somewhere arbitrary. Shared components like ingress controllers and monitoring will need a split policy nobody has agreed on. Under showback, a team that disputes its number prompts a fix to the labels or the split rules. Under chargeback, the same dispute becomes an argument about real money. Run showback until teams trust the numbers, then decide whether chargeback is worth the extra process.

This tutorial is for platform teams running multi-tenant clusters, where several teams share nodes and the cloud bill shows only node and storage costs, not who used them.

Adopt showback when spend on shared clusters is growing and nobody can say which team drove the increase.

Postpone it in these cases:

  • Single-team clusters. Account-level billing already answers the question.
  • Managed services outside the cluster dominate spend. In-cluster allocation will miss most of the bill.
  • No one can maintain labeling discipline. Without consistent labels, the reports will drift into a large "unallocated" bucket that nobody acts on.

How does OpenCost allocate cost to pods, namespaces, and labels?

OpenCost builds cost bottom-up from data already in your cluster. It reads Prometheus metrics for each container's CPU, memory, GPU, and storage requests and its actual usage. It then prices those resources using node costs taken from the cloud provider's public pricing, or from a custom pricing config for on-prem or negotiated rates. Cost lands on individual pods first. Namespaces, labels, controllers, nodes, and other dimensions are aggregations of those pod-level figures. Your team-level showback is therefore only as good as the labels on the pods underneath it.

The key modeling choice is whether a pod pays for what it reserved or what it consumed. By default, OpenCost charges the greater of the two, so neither over-requesting nor bursting past requests goes unbilled.

Basis Charges for Rewards Penalizes
Request-based Reserved capacity Accurate sizing Padded requests
Usage-based Consumed resources Bursty, low-average workloads Hides waste from oversized requests
Max(request, usage) Whichever is higher Right-sized requests Both padding and unbounded bursting

Illustrative estimate (assumed numbers, not a benchmark). cost = max(request, usage) × hours × unit price

Assume a pod requests 2 vCPU, averages 0.5 vCPU, runs 730 hours, and the node's derived price is $0.03 per vCPU-hour. The calculation is 2 × 730 × 0.03 = $43.80. That pod pays for the capacity it blocked others from using, not the capacity it burned.

Pricing caveat: List prices ignore committed-use discounts, savings plans, enterprise agreements, and spot rates. Until you reconcile against actual billing data, treat absolute dollar figures as relative signals rather than invoice-accurate amounts.

+----------------------+        +-----------------------------+
| Prometheus metrics   |        | Node pricing                |
| - requests (CPU,mem, |        | - cloud provider list price |
|   GPU, storage)      |        | - or custom pricing config  |
| - actual usage       |        |   (on-prem / negotiated)    |
+----------+-----------+        +--------------+--------------+
           |                                   |
           +-----------------+-----------------+
                             v
        +------------------------------------------+
        | OpenCost cost model (per pod/container)  |
        | cost = max(request, usage)               |
        |        x hours x unit price              |
        +--------------------+---------------------+
                             v
        +------------------------------------------+
        | Pod-level cost (carries pod labels)      |
        +--------------------+---------------------+
        +-------------+------+------+-------------+
        |             |             |             |
        v             v             v             v
  +-----------+ +-----------+ +-----------+ +-----------+
  | Namespace | | label:team| | Controller| | Node, ... |
  +-----------+ +-----+-----+ +-----------+ +-----------+
                      v
        +------------------------------------------+
        | Per-team showback                        |
        | relative signal until reconciled with    |
        | billing data (list prices lack discounts)|
        +------------------------------------------+

OpenCost combines Prometheus request and usage metrics with node pricing to cost each pod at max(request, usage), then aggregates pod costs by namespace, label, controller, and node into per-team showback that stays a relative signal until reconciled with billing data.

Designing a label taxonomy before you install anything

Allocation can only be as granular as the metadata on your workloads, so settle the labels before OpenCost starts collecting data. OpenCost aggregates by whatever label keys exist. If one team writes team, another writes owner, and a third writes Team, you get three separate buckets that someone has to merge by hand every month.

Start with three required keys:

  • team: the group that owns the spend and answers questions about it.
  • service: the deployable unit, so a team can see which of its services costs the most.
  • environment: a fixed set such as prod, staging, and dev.

Pick one format for values and enforce it: lowercase and hyphenated. Kubernetes label values are capped at 63 characters and must start and end with an alphanumeric character. Teams get renamed and reorganized, so use stable team identifiers rather than display names or people's names.

Namespace labels, workload labels, or both

Placement Works well when Breaks down when
Namespace only One team owns the whole namespace Several teams share a namespace, or a shared component like ingress or monitoring serves everyone
Workload only Ownership varies within a namespace Engineers forget the labels without enforcement, and unlabeled pods fall into an "unallocated" bucket
Both You want a namespace default with per-workload overrides You need to document which label takes precedence

The combined approach is usually the safest choice. With a clear default and a documented override rule, you avoid backfilling labels across hundreds of manifests later. You also avoid the monthly spreadsheet reconciliation that turns showback into a chore nobody wants to own.

# Namespace default: one team owns most of what runs here.
apiVersion: v1
kind: Namespace
metadata:
  name: checkout
  labels:
    team: payments-core        # stable team ID, not a display name
    environment: prod
---
# Workload override: another team runs a service in the same namespace.
apiVersion: apps/v1
kind: Deployment
metadata:
  name: fraud-scoring
  namespace: checkout
  labels:
    team: risk-platform
    service: fraud-scoring
    environment: prod
spec:
  replicas: 2
  selector:
    matchLabels:
      app: fraud-scoring
  template:
    metadata:
      # Cost is allocated per pod, so ownership labels must be on the
      # pod template, not only on the Deployment's own metadata.
      labels:
        app: fraud-scoring
        team: risk-platform      # overrides the namespace default
        service: fraud-scoring
        environment: prod
    spec:
      containers:
        - name: fraud-scoring
          image: registry.example.com/risk/fraud-scoring:1.0.0
          resources:
            requests:
              cpu: 250m
              memory: 256Mi

A namespace carries default team and environment labels, while a Deployment from a second team sets its own team, service, and environment labels on the pod template to override that default inside the shared namespace.

How do you enforce namespace labels and workload labels at admission time?

Put the team label in two places. On the namespace, it is the default owner. On the pod template (spec.template.metadata.labels), it is the label OpenCost reads when you aggregate by label. Labels on the Deployment object alone don't reach the pods, and that is the most common reason a "labeled" workload still shows up unallocated.

Enforcing with ValidatingAdmissionPolicy

A ValidatingAdmissionPolicy can check that every pod-creating object carries team in its pod template, and that the value is on an allowed list. Checking the value matters because a typo like paymnets doesn't fail loudly. It creates a phantom team that nobody reads in the report.

The binding's validationActions controls the rollout:

  • Start with Warn and Audit. This shows offenders to the people deploying and in the audit log, without breaking any pipelines.
  • Switch to Deny later. Do this once the warnings stop, and exempt system namespaces explicitly.

If you go straight to Deny, someone will add a blanket exemption to unblock a release, and it will probably never be removed.

Tracking the unallocated bucket

Anything without the label lands in OpenCost's __unallocated__ aggregate when you group by team. Nothing alerts on it, so it can grow without anyone noticing. Track its share of total cost as a health metric:

unallocated_share = unallocated_cost / total_allocated_cost

Illustrative estimate (assumed numbers, not a benchmark):

  • Total monthly allocated cost: $40,000
  • Unallocated cost: $6,000
  • Unallocated share: 6,000 / 40,000 = 15%

At that level, 15% of the bill has no owner, and every per-team number in the report is understated. Set a threshold, such as under 5%, and report the trend weekly alongside the showback data.

# Requires team on the pod template (what OpenCost reads), not just the workload.
# admissionregistration.k8s.io/v1 is GA as of Kubernetes 1.30.
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
  name: require-team-label
spec:
  failurePolicy: Fail
  matchConstraints:
    resourceRules:
    - apiGroups: ["apps"]
      apiVersions: ["v1"]
      operations: ["CREATE", "UPDATE"]
      resources: ["deployments", "statefulsets", "daemonsets"]
  validations:
  # Check the value against an allow-list so typos like 'paymnets' are caught too.
  - expression: >-
      has(object.spec.template.metadata.labels) &&
      'team' in object.spec.template.metadata.labels &&
      object.spec.template.metadata.labels['team'] in ['payments', 'search', 'platform']
    message: "spec.template.metadata.labels.team must be one of: payments, search, platform"
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicyBinding
metadata:
  name: require-team-label-binding
spec:
  policyName: require-team-label
  # Audit-first rollout: surface offenders without blocking deploys.
  # Change to ["Deny"] once warnings stop appearing.
  validationActions: ["Warn", "Audit"]
  matchResources:
    # Explicit, reviewable exemption for system namespaces.
    namespaceSelector:
      matchExpressions:
      - key: kubernetes.io/metadata.name
        operator: NotIn
        values: ["kube-system", "kube-public", "kube-node-lease"]

A ValidatingAdmissionPolicy and binding that require an allow-listed team label on pod templates of apps/v1 workloads, starting in Warn and Audit mode before switching to Deny.

How do you install OpenCost and query allocation by team?

With admission control keeping labels clean, install OpenCost with its Helm chart and point it at your existing Prometheus rather than running a second one. Two Prometheus servers scraping the same kubelets add load and can disagree about what ran. If you have no Prometheus, use the bundled one, but treat it as production infrastructure from day one.

Before building any report, confirm the cost model is producing data. Use kubectl port-forward to reach the OpenCost service and query the allocation API for a short window, such as the last hour. You should see your namespaces with non-zero CPU and memory cost. Empty or all-zero results usually mean OpenCost cannot reach Prometheus, or the cAdvisor and kube-state-metrics series are missing.

Then aggregate by the dimensions your taxonomy defines. Set the aggregate parameter to namespace for a first pass, and to label:team for showback. Choose the window to match your reporting cadence. Use a fixed, closed range such as last week instead of a rolling "7d" window, so that reruns return the same numbers. The UI exposes the same aggregation and is useful for spot checks.

OpenCost computes history from Prometheus, so Prometheus retention caps how far back you can report. Scrape gaps also distort the record in two ways:

  • Missed scrapes: if a pod is missed during a scrape, its cost silently drops.
  • Restarts: if Prometheus restarts mid-month, that interval is simply missing from the data.

Alert on scrape failures, and size Prometheus storage for the label cardinality your taxonomy adds.

#!/usr/bin/env bash
set -euo pipefail

# Install OpenCost from its Helm chart. This assumes the opencost Helm repo is
# already added per the project docs. opencost-values.yaml points the cost
# model at your existing Prometheus; check the key names against the chart's
# values.yaml for your chart version.
helm install opencost opencost/opencost \
  --namespace opencost --create-namespace \
  -f opencost-values.yaml

# Reach the OpenCost API locally. 9003 is the cost-model API port.
kubectl -n opencost port-forward service/opencost 9003:9003 >/dev/null &
PF_PID=$!
trap 'kill $PF_PID' EXIT
sleep 3

API=

# 1) Smoke test: a short window should show non-zero CPU and RAM cost per
#    namespace. All zeros or an empty list usually means OpenCost can't reach
#    Prometheus, or the cAdvisor/kube-state-metrics series are missing.
curl -sG "$API" -d window=1h -d aggregate=namespace \
  | jq '.data[0] | to_entries[] | {ns: .key, cpu: .value.cpuCost, ram: .value.ramCost}'

# 2) Showback by team label over a fixed, closed range (RFC3339 start,end).
#    Reruns over the same range return the same numbers, unlike a rolling 7d.
WINDOW="2026-11-02T00:00:00Z,2026-11-09T00:00:00Z"
curl -sG "$API" -d window="$WINDOW" -d aggregate=label:team \
  | jq '.data[0] | to_entries[] | {team: .key, total: .value.totalCost}'

# Workloads with no team label land in an unallocated bucket. Track that
# bucket's share of total cost as a measure of label hygiene.

Installs OpenCost with Helm against an existing Prometheus, then uses port-forward and the allocation API to run a smoke test by namespace and a fixed-window showback query by the team label.

How should you handle idle, shared, and system costs?

Every cluster carries cost that no single team's pod explains. That includes control-plane and node overhead, kube-system and other system namespaces, monitoring and ingress shared by everyone, and idle capacity, meaning node cost not covered by any workload's requests. OpenCost reports idle as its own allocation rather than hiding it. How you distribute it is a policy decision, not a technical fact.

Approach How it works Strength Weakness
Leave unallocated Report as a separate "platform" line Honest; shows the platform's own efficiency Team totals look cheaper than reality
Split evenly Divide equally across N teams Simple to explain Small teams subsidise large ones
Split proportionally Weight by each team's requests or usage Tracks who drives capacity Harder to explain; shifts month to month

Weighting by requests is usually more defensible than weighting by usage. Nodes are provisioned for what pods reserve, so over-requesting teams cause idle capacity.

Illustrative estimate (assumed numbers, not a benchmark): assume $3,000/month idle and shared cost. Team A holds 60% of cluster CPU requests, B holds 30%, and C holds 10%.

team share = shared cost × (team requests ÷ total requests)

That gives A $1,800, B $900, and C $300. An even split would charge each team $1,000.

Write the chosen rule down, publish it with the report, and expect teams to dispute it. Also state plainly that OpenCost sees only in-cluster resources. Managed databases, object storage, and some network egress are billed elsewhere, so per-team totals understate the true cost of running a service.

Building a recurring per-team showback report

Run the allocation query once per billing month with a fixed window and team-level aggregation. Store the output with the price inputs used, because a later pricing change will otherwise make old reports impossible to reproduce. The table below shows how one team's line is built.

Illustrative estimate. All inputs are assumed and are not measured. A node costs $0.40/hour, split into $0.032 per vCPU-hour and $0.0045 per GiB-hour. A month is 730 hours. The payments team requests 6 vCPU and 24 GiB continuously. Cluster idle cost is $1,000/month, and payments holds 15% of requested cost.

Line item Calculation Monthly
CPU requests 6 × $0.032 × 730 $140.16
Memory requests 24 × $0.0045 × 730 $78.84
Idle share 15% × $1,000 $150.00
Total $369.00

A bare total invites the wrong fix. Put p95 CPU and memory usage next to requests for each workload. A team that sees "requests 24 GiB, p95 usage 9 GiB" can safely trim requests. A team that only sees "$369" may cut CPU below its peak and get throttled, or set memory below its working set and trigger OOM kills. Mark which workloads have headroom and which are already tight.

Showback also changes where engineering time goes. Sorting each team's line items by the gap between requested and used makes over-provisioning visible. Teams can then spend an afternoon resizing their two largest deployments rather than tuning every service. Keep the idle share as a separate line, so teams can tell their own over-provisioning apart from cluster-level waste that the platform team owns.

What are the alternatives to OpenCost for Kubernetes cost allocation?

OpenCost is not the only way to get per-team numbers. The right choice depends on how your clusters are shared and how much engineering time you want to spend on the reporting pipeline.

Option Good enough when Where it breaks down
Kubecost You want a supported product with a UI, alerting, and multi-cluster views You need a fully open-source stack, or the licensing cost outweighs the convenience
Cloud billing export with cost allocation tags Teams own whole node pools, clusters, or accounts Many teams share nodes, because tags apply to cloud resources, not to pods
Custom Prometheus queries You only need raw usage (CPU-hours, GiB-hours) by label You must keep pricing data, idle-cost logic, and shared-cost rules up to date yourself
Spreadsheet keyed on namespace You have a few namespaces that rarely change, and need a rough monthly split It goes stale as soon as teams add workloads or move between namespaces

Kubecost grew out of the same project. The open cost model was donated as OpenCost, and Kubecost adds a commercial layer on top of it. If you already plan to buy tooling, evaluating Kubecost is reasonable, because the underlying allocation logic is closely related.

OpenCost is the better fit in two cases:

  • Shared nodes. Multiple teams run on the same nodes, so billing exports cannot attribute cost below the node level.
  • Open-source and self-hosted. You want an open-source, self-hosted allocation engine that applies the namespace labels and workload labels you enforce at admission. That saves you from re-implementing pricing and idle-cost handling in hand-written queries.

How OneEnv can help

Disclosure: OneEnv is the product behind this blog.

OneEnv (oneenv.io) is a workspace-based governance platform for the things services share — environment variables, database structure, API routes and validation rules. A change to a shared value is staged on a branch, reviewed once, and then every affected service explicitly approves or rejects it before it goes live, so you can see who a change touches before it ships instead of finding out in production.

Applied to opencost cost allocation, this is where it helps:

Saves time

  • Every service that inherits a shared value is listed in one place, so nobody searches repos and chats to find out who is affected.
  • One review per branch replaces coordinating each team separately; each service still keeps its own approve/reject.
  • Reviewers see the exact diff and the list of affected services up front, so approval is a decision rather than an investigation.

Saves cost

  • Fewer production incidents and rollbacks caused by a shared value, route or column changing under a consumer unannounced.
  • Less duplicated configuration to maintain: one shared definition inherited by many services.
  • Per-service approve/reject means a bad shared value can be refused where it would break something, before it is live.
  • OneEnv has a free plan (1 workspace, unlimited services and members, full governance), so trying it costs nothing.

These are qualitative benefits, not measured results — how much you save depends on how many services share the value.

Want to try it? Start at oneenv.io.