Master Kubernetes cost optimization with this hands-on Kubecost tutorial. Learn how to track spending and implement FinOps for Kubernetes in your production stack.
Managing cloud infrastructure cost is usually a headache. You spin up an EKS or GKE cluster, deploy a few dozen microservices, and suddenly your monthly AWS or GCP bill looks like a phone number. If you’re like me, you’ve spent too many hours staring at billing dashboards, trying to figure out which team or namespace is burning through the budget.
That’s where Kubecost comes in. It’s the industry standard for mapping Kubernetes spending to specific teams, applications, and environments. In this guide, I’ll show you how to get it running and—more importantly—how to actually save money.
First, we need to get the tool running. I recommend using Helm for this. Assuming you’re running a standard cluster (I’m currently on K8s 1.28), grab the latest chart.
Bashhelm repo add kubecost https://kubecost.github.io/cost-analyzer/ helm repo update kubectl create namespace kubecost helm install kubecost kubecost/cost-analyzer \ --namespace kubecost \ --set kubecostToken="YOUR_TOKEN_HERE"
Once the pods are up, port-forward to your local machine:
Bashkubectl port-forward --namespace kubecost deployment/kubecost-cost-analyzer 9090:9090
Head to http://localhost:9090. You’ll immediately see a breakdown of your spend. If you haven't set up cloud billing integrations yet, you're only seeing "cluster cost." To get real-world numbers, you need to provide your cloud provider's billing export (like AWS Cost and Usage Reports or GCP BigQuery billing exports). This is the foundation of effective FinOps for Kubernetes.
Visibility is just the start. Once you see the numbers, you’ll notice the usual suspects: over-provisioned requests, idle clusters, and under-utilized nodes. Here’s how I tackle them.
Most developers set "safe" resource requests. They'll set 2GB of RAM for a service that actually uses 200MB. That 1.8GB gap is wasted money.
Kubecost provides a "Savings" tab that identifies these over-provisioned workloads. My rule of thumb: review the "Recommended Requests" column in the Kubecost UI every two weeks. If a service consistently uses less than 40% of its requested memory, I slash the request limit by 20% and observe.
Stop manual guessing. If you’re on a managed K8s provider, deploy the Vertical Pod Autoscaler in Recommendation mode. It won't restart your pods, but it will suggest the perfect request values based on real-time usage.
If your workloads are fault-tolerant (like stateless frontend pods or worker nodes), use Spot Instances. You can save up to 90% compared to On-Demand pricing. Use Kubecost to calculate exactly how much you're saving by moving specific deployments from On-Demand to Spot.
You don't want to check a dashboard every day. That’s not engineering; that’s babysitting. Use Kubecost’s Alerting API to catch budget overruns before they hit your finance department.
I set up alerts for high-cost namespaces. If a development namespace suddenly spikes in spend, I get a Slack notification. It usually means someone left a load balancer or an oversized PVC running in a dev environment.
YAML# Example alert configuration snippet alerts: - name: "High Cost Namespace Alert" threshold: 500 period: "daily" notificationURL: "https://hooks.slack.com/services/..."
Cloud infrastructure cost management isn't a one-time task. It’s an iterative loop: Monitor → Analyze → Optimize → Repeat.
Don’t try to optimize everything at once. Start with your largest namespace. Reduce the requests for your top three most expensive services. Once you see the savings, you’ll find that FinOps isn't about being cheap—it's about being efficient. It’s about ensuring every dollar spent is actually delivering value to your users.
If you’re just starting, spend a week just observing. Don't touch a single deployment. Let Kubecost collect the data. Once you have a week of baseline, you'll have the empirical evidence needed to justify the resource cuts to your product team.
Master Kubernetes cost monitoring with Kubecost. Learn how to implement granular resource allocation and drive FinOps practices to optimize your cloud spend.
Read moreMaster Kubernetes multi-tenancy with the Hierarchical Namespace Controller (HNC). Learn how to implement hierarchical namespaces for better resource isolation today.