See Kubernetes costs by namespace
See what each namespace in an AKS, EKS or GKE cluster costs, without installing
anything in the cluster. leancosts reads the allocation the cloud provider
itself computes and serves it three ways: the Kubernetes tab on the Costs
page, the get_kubernetes_costs tool on the leancosts MCP server, and
GET /api/costs/kubernetes. leancosts is read-only here as everywhere: it
never enables anything and never touches the cluster. For the full posture see
Security and data handling.
Before you start
Section titled “Before you start”- The subscription / account / project that hosts the cluster is connected and has synced at least once.
- For AWS, the connection reads a Cost and Usage Report. Cost Explorer does not carry namespace data, so a connection without a CUR cannot show it.
- For Azure, the cluster is on the Standard or Premium tier. The add-on is not available on the Free tier.
- Your agent is connected to leancosts (see Connect Claude to leancosts) if you want to ask rather than click.
1. Turn on cost allocation, once per cluster
Section titled “1. Turn on cost allocation, once per cluster”This is the only step leancosts cannot do for you. Run the one for your cloud.
Azure (AKS), the cost analysis add-on, per cluster:
az aks update --ids "<cluster-resource-id>" \ --tier standard --enable-cost-analysisGoogle Cloud (GKE): cost allocation, per cluster. Autopilot clusters already have it on:
gcloud container clusters update <name> \ --location <loc> --project <p> --enable-cost-allocationAWS (EKS): an account-wide billing preference, not a CLI flag. In the AWS console, open Billing and Cost Management → Cost management preferences, enable Split cost allocation data, and then include it in the CUR export that the leancosts connection reads.
Each provider starts publishing within about a day (AWS prepares the current month, Google can take up to three days); nothing older is backfilled.
2. Wait for the next sync
Section titled “2. Wait for the next sync”Every connector sync re-reads the recent window for the accounts it owns. You
can trigger one from Connections or with the trigger_sync tool.
3. Read it
Section titled “3. Read it”In the app: open the Costs page and pick the Kubernetes tab. One card per cluster with its provider, account and an allocation status chip; under it the namespaces ranked by cost with a share bar, and a 1 / 2-month toggle.
With an agent: some questions get_kubernetes_costs answers:
- “Which namespaces cost the most in the payments cluster this month?”
- “How much of that cluster is idle or unused?”
- “Do all our clusters have cost allocation enabled?”
From a script: GET /api/costs/kubernetes?months=2 returns the same body.
What the rows mean
Section titled “What the rows mean”Alongside the real namespaces, each provider emits its own buckets:
| Row | Cloud | Meaning |
|---|---|---|
| a namespace | all | the share of node, disk and load-balancer cost attributed to its pods |
Idle | Azure | capacity no namespace requested |
System | Azure | kube-system and other platform namespaces |
Unallocated | Azure | cost the add-on could not attribute |
Service | Azure | the cluster’s uptime SLA fee |
unused | AWS | the pods’ share of idle node capacity |
goog-k8s-unsupported-sku | Google Cloud | SKUs GKE cost allocation does not split |
goog-k8s-unknown | Google Cloud | usage GKE could not attribute to a namespace |
Verify
Section titled “Verify”Open the Costs page’s Kubernetes tab, or call the tool. You should see every cluster leancosts knows, per cloud, with its status chip, and namespace rows under the clusters where allocation is on. If a cluster shows rows, it worked.
If there is no data
Section titled “If there is no data”The response lists every cluster with its allocation flag, so the two failure modes are distinguishable:
- Allocation off on every cluster: step 1 has not happened. The empty state shows the exact command to run.
- Allocation on but no rows: the provider has not published the first day yet, or the connector has not synced since. Try again after the next sync.
- An EKS cluster with no rows: leancosts cannot read the AWS preference, so check that Split cost allocation data is both enabled and included in the CUR export the connection reads.