Install Kubecost on Kubernetes
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.
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.
Step 1: Add the Helm repository
helm repo add kubecost https://kubecost.github.io/cost-analyzer/
helm repo updateStep 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.
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.