# Kubernetes cost by namespace and team

A cluster's bill names nodes, not the teams that run workloads on them. This guide installs the agent with the labels that name teams, turns those labels into one tag, assigns each namespace to a segment, and reports cost per namespace and team. Each step links to the page that owns the detail.

## Before you start

- A cluster to install the agent on, and the AWS, Azure or Google Cloud connection that pays for its nodes, or the rates to price them by; see [Connect Kubernetes](/connect/kubernetes).
- The label that names a team on your pods or namespaces, such as `team`, and the namespaces that carry none.
- The Owner or Editor team role in the workspace; see [Access model](/concepts/access-model).

## 1. Send the labels

Install the agent with `agent.allowedLabels` naming the pod labels to send, or empty for all of them, and `agent.collectNamespaceLabels=true` when the team label sits on the namespace. Each label reaches reports as a tag named `k8s:label:<key>`, and every row also carries `k8s:cluster`, `k8s:namespace`, `k8s:node` and `k8s:pod`. Cost appears the morning after the install. See [Install the agent](/connect/kubernetes#install-the-agent) and [Reporting dimensions](/connect/kubernetes#reporting-dimensions).

## 2. Make one team tag

Create a virtual tag `team` whose provider tag keys read `k8s:label:team` first and your other spellings after it, and add a rule for each namespace that carries no label, with a **Namespace** condition and the team as its value. Check the preview until "Unmatched" is small. See [Virtual tags](/allocation/virtual-tags).

## 3. Assign namespaces to segments

Add one segment per team and one rule per segment: a rule cannot read a virtual tag, so give it a **Namespace** condition naming the team's namespaces, or a **Tag** condition on `k8s:label:team`. Idle cost sits in the namespace `__idle__`; a rule can assign it to a platform segment, or you leave it unallocated to keep it visible. See [Segments and allocation rules](/allocation/segments).

## 4. Report per namespace and team

Group by **Namespace** for the allocation, or by **Virtual tag** `team` for the teams, and add **Cluster** when there are several. A cluster's rows count only when a report asks for Kubernetes, by a grouping or filter on provider, cluster, namespace or a `k8s:` tag, so a report grouped by **Segment** alone leaves them out: add **Namespace** as a second grouping, or filter **Provider** to Kubernetes. See [How totals count a cluster](/connect/kubernetes#how-totals-count-a-cluster) and [Explore cost data](/cost-reports/explore).

## 5. Deliver it

Save the report, and for each team a copy filtered by **Virtual tag** to its value, and schedule each weekly to the team. See [Save and manage reports](/cost-reports/manage) and [Share and schedule reports](/cost-reports/share-and-schedule).

## Keep it true

- A new namespace appears under **Namespace** with its first processed day, and under "Unmatched" until a label or a rule names its team.
- A node without a price is counted as unpriced on the cluster and appears in no namespace; the cluster's status says so. See [How costs are calculated](/connect/kubernetes#how-costs-are-calculated).

## Related

- [Showback for teams](/guides/showback-for-teams)
