Install Kubecost on Kubernetes
Quick answer
Deploy Kubecost on Kubernetes with Helm, expose the dashboard, and start tracking per-namespace and per-deployment cloud spend — with budget alerts so you find out before your bill does.
- Step 1: Add the Helm repository
- Step 2: Create the kubecost namespace
- Step 3: Install Kubecost
- Step 4: Wait for pods to be ready
- Step 5: Expose the dashboard
intermediate · 20 min
Before you begin
- A running Kubernetes cluster
- kubectl configured with cluster access
- Helm 3 installed
Kubernetes gives you very little cost visibility out of the box. You can see CPU and memory requests per pod, but translating that into dollars — broken down by namespace, team, or deployment — requires something else. Kubecost fills that gap. It runs inside your cluster, scrapes metrics from Prometheus, and produces real-time cost attribution that you can actually act on.
This tutorial installs Kubecost, exposes the dashboard, and configures a budget alert so you know when a namespace starts burning unexpectedly. See our FinOps tool showdown if you're also weighing Kubecost against Vantage or Infracost.
Step 1: Add the Helm repository
helm repo add kubecost https://kubecost.github.io/cost-analyzer/
helm repo updateNote: Kubecost was acquired by Grafana Labs in 2024. The install URL and chart structure have evolved. If this repo add fails or you want to use the current canonical method, check the official Kubecost install docs for the latest guidance — the OCI registry path may be preferred for newer versions.
Step 2: Create the kubecost namespace
kubectl create namespace kubecostStep 3: Install Kubecost
For a quick evaluation, disable persistent volumes so the install is stateless. For production, remove those flags and let Prometheus retain historical data.
helm install kubecost kubecost/cost-analyzer \
--namespace kubecost \
--set prometheus.server.persistentVolume.enabled=false \
--set prometheus.alertmanager.persistentVolume.enabled=falseStep 4: Wait for pods to be ready
The first start takes 2–3 minutes while images pull and Prometheus initialises.
kubectl get pods -n kubecost --watchExpected output — all pods Running:
NAME READY STATUS RESTARTS
kubecost-cost-analyzer-6b9d8f7c4-xkq2p 3/3 Running 0
kubecost-prometheus-server-79b7d6c9f5-rtz8m 2/2 Running 0
Step 5: Expose the dashboard
Port-forward the cost-analyzer deployment to your local machine:
kubectl port-forward deployment/kubecost-cost-analyzer 9090 -n kubecostOpen http://localhost:9090 in your browser. Allow 30–60 minutes for cost data to populate on a typical cluster — the first reconciliation takes longer on clusters with many namespaces. Kubecost needs time to scrape Kubernetes metrics and calculate cost allocations.
Step 6: Explore the dashboard
The Allocations view is where most of the value is. Navigate to Allocations → Namespace and you'll see a breakdown of estimated spend per namespace for the current month. Drill down to Deployment for per-workload costs.
Key metrics to check first:
- Idle cost — resources allocated but not used. High idle cost means oversized requests.
- Efficiency — ratio of used vs requested resources per deployment.
- Cost over time — spot sudden spikes that indicate a runaway workload.
Step 7: Create a budget alert
Kubecost budget alerts are configured through the UI — there is no CRD-based API for budgets.
Navigate to Alerts → Add Alert → Budget in the Kubecost UI. Configure:
- Allocation: Namespace →
default - Budget amount: $500/month
- Threshold: 80% (fires at $400 to give early warning)
- Notification: email or Slack webhook
Kubecost also supports alerts via its HTTP API at POST /model/budget if you want to script alert creation.
Step 8: Integrate with your cloud billing (optional)
For accurate costs rather than estimates based on on-demand pricing, connect Kubecost to your cloud billing data:
AWS: Configure a Cost and Usage Report (CUR) in S3 and add the S3 URI to your Kubecost Helm values:
1helm upgrade kubecost kubecost/cost-analyzer \
2 --namespace kubecost \
3 --reuse-values \
4 --set kubecostProductConfigs.athenaProjectID=<your-account-id> \
5 --set kubecostProductConfigs.athenaBucketName=your-cur-bucket \
6 --set kubecostProductConfigs.athenaRegion=us-east-1 \
7 --set kubecostProductConfigs.athenaDatabase=athenacurcfn_db \
8 --set kubecostProductConfigs.athenaTable=<your-table-name> \
9 --set kubecostProductConfigs.athenaWorkgroup=primaryKubecost also needs IAM permissions to query S3 and Athena. Use IRSA (annotate the kubecost-cost-analyzer service account with your IAM role ARN) or set kubecostProductConfigs.awsServiceKeyName and kubecostProductConfigs.awsServiceKeySecret — though IRSA is strongly preferred over static credentials.
Without billing integration, Kubecost uses public on-demand pricing — which overestimates cost for Reserved Instances and Spot. Connecting billing gives you actual costs with discounts applied.
What you built
Kubecost is running in your cluster, scraping cost data from the Kubernetes metrics API. The dashboard shows real-time spend broken down by namespace, deployment, label, and node. A budget alert will fire when spend in the default namespace approaches $500/month. Once you connect cloud billing, the estimates become actuals.
The next step is to share namespace-level cost dashboards with individual teams — team-scoped views with SSO-based RBAC are available in Kubecost Enterprise.
Frequently Asked Questions
Why do Kubecost's numbers differ from my cloud bill?
They measure different things. Kubecost allocates cost based on what workloads requested and used, priced against list or your negotiated rates. The bill reflects what the provider actually charged, including idle capacity, data transfer and account-level discounts. The gap between them is roughly the cost of capacity you are paying for and not using, which is often the most useful number available.
Do I need to connect billing data?
Not to start — Kubecost estimates from public pricing and gives useful relative allocation immediately. Connecting billing replaces estimates with actual rates including your discounts and commitments, which matters once you are using the figures for chargeback rather than for finding the biggest consumer.
How long before the data is useful?
Allocation appears within minutes but reflects only what it has observed, so early numbers are not representative. Wait for at least a full weekly cycle before drawing conclusions, since weekend and batch patterns change the picture substantially.
Does Kubecost see costs outside the cluster?
Only what you connect. Managed databases, object storage and anything else outside Kubernetes are invisible to in-cluster allocation unless billing integration surfaces them. Use it for the attribution question — which namespace, which team — and your provider's tooling for the total.
Official References
- Helm chart template guide — templates, values and the sprig function set
- Helm charts — chart structure, dependencies and hooks
- AWS Savings Plans — plan types, commitment terms and how discounts apply
- EC2 Spot Instances — interruption behaviour and capacity rebalancing
We built Podscape to simplify Kubernetes workflows like this — logs, events, and cluster state in one interface, without switching tools.
Struggling with this in production?
We help teams fix these exact issues. Our engineers have deployed these patterns across production environments at scale.