Kubernetes cost allocation in one afternoon
Kubernetes is a cost allocation nightmare by default. A cluster gets a single bill, but it runs dozens of workloads for multiple teams. Here's how to carve it up without buying a commercial tool.
Step 1: label everything (30 minutes)
Every namespace gets an owner and application label. Every deployment gets a team annotation. If a resource doesn't have these, it gets triaged into an "unowned" bucket.
Step 2: deploy an open-source cost allocator (90 minutes)
Three options:
- OpenCost — the CNCF-graduated successor to Kubecost-free. Runs in your cluster, writes metrics to Prometheus, shows you per-namespace cost.
- Kubecost community edition — similar, broader UI features.
- Built from Prometheus — if you have Prometheus + node exporter + kube-state-metrics, you can build the queries yourself with some SQL-like work.
For most teams, OpenCost is the starting point.
Step 3: define a pricing model (30 minutes)
You need to tell the allocator: what does a core-hour cost, what does a GB-hour cost, what does a GB-month of storage cost. Get these from your cloud provider's on-demand pricing (or average your last 3 months of cloud bill / actual resource-hours).
Step 4: allocate shared costs (60 minutes)
Some costs are shared: the cluster control plane, ingress controllers, monitoring stack, DNS. Decide: do you split these evenly across all namespaces, proportional to usage, or attribute to a "platform" cost center? Most teams proportional-to-usage works; platform as a bucket is cleaner.
Step 5: set up a weekly report (30 minutes)
Export allocator data to a sheet or dashboard. Share it with engineering leads. The visibility itself drives 10–20% cost reduction in the first quarter.
Tools
- Kubernetes Cost Allocator for quick manual allocation by workload type.
- Rightsizing Recommender to find oversized pods.