Infracost vs OpenCost vs Kubecost: cloud cost visibility pick for 2027
Infracost vs OpenCost vs Kubecost for small teams heading into 2027 budgeting: one prices Terraform changes before deploy, two allocate running Kubernetes cost. Scored on five criteria, with a blunt verdict on who needs which.
Today is Hari Tabungan Sedunia, World Savings Day, and it lands on the last day of the month. That is a good excuse to close the books on October honestly before 11.11 promos and 2027 budget meetings take over November. For a lot of small teams I talk to around Karawaci and BSD, the line that is hardest to explain in that budget meeting is not salaries or SaaS seats. It is the cloud bill, and specifically the question “why did it go up?” So this month’s pick is Infracost vs OpenCost, with Kubecost as the third option, for teams that want cloud cost visibility instead of a monthly surprise.
Two scope notes before we start.
First, billing alerts are out of scope here. If you have not set up AWS Budgets, GCP budget notifications or Cloudflare usage notifications yet, stop and do that first with the sister site’s guide, Pasang Budget Alert AWS, GCP, Cloudflare Sebelum Tagihan Bikin Kaget. Alerts tell you that the total is going up. The three tools below tell you which change or which service is responsible. I am assuming you already have the safety net.
Second, this is about cloud infrastructure spend, not tool subscriptions. My Q3 stack review audited which SaaS seats were actually earning their keep. This piece is about the compute, storage and network under your apps.
Three tools, three different moments
The most common mistake I see is treating these three as competitors in the same category. They are not. They surface cost at different points in the lifecycle:
- Infracost works before deploy. It reads your Terraform code and posts the monthly cost difference of a change on the pull request, so the reviewer sees “+USD X/month” next to the diff.
- OpenCost works at runtime, inside Kubernetes. It is an open source CNCF project that takes node prices and resource usage and allocates the running cost of a cluster by namespace, deployment, pod, controller or label.
- Kubecost also works at runtime, and it is built on OpenCost. It adds a fuller UI, savings recommendations, multi-cluster views and enterprise features on top of the same allocation model.
So the first question is not “which is best”. It is “where does our cost problem actually live: in changes nobody priced, or in a cluster nobody can break down?”
The five criteria
- When cost shows up. Pre-deploy (in review) or runtime (after the money is already being spent).
- Setup effort. Minutes in CI, or a Helm install plus Prometheus plus ongoing upkeep.
- Do you need Kubernetes at all? A tool that only understands clusters is useless to a team on VMs or serverless.
- Accuracy of shared and idle cost. Who pays for
kube-system, the monitoring stack, and the half-empty node at 3 a.m. - Licensing. Open source, free tier, or paid, and what happens to the bill when the team grows.
Comparison table
| Criterion | Infracost | OpenCost | Kubecost |
|---|---|---|---|
| When cost surfaces | Pre-deploy, on the PR | Runtime, in the cluster | Runtime, in the cluster |
| Input | Terraform HCL (plus usage file for usage-based resources) | Prometheus metrics + node pricing | Same model as OpenCost, plus its own data store |
| Needs Kubernetes | No | Yes | Yes |
| Setup effort | Low: CLI or CI action + API key | Medium: Helm chart + Prometheus | Medium: Helm chart, more config for multi-cluster and billing reconciliation |
| Shared and idle cost | Not applicable (estimates list price of declared resources) | Idle reported separately; sharing via API parameters | Configurable idle and shared-cost rules in the UI |
| Savings recommendations | Policy checks in paid Infracost Cloud | Minimal | Yes (rightsizing, abandoned workloads, unclaimed volumes) |
| Licensing | CLI open source (Apache-2.0); Infracost Cloud is a paid product | Open source (Apache-2.0) | Proprietary; free tier plus paid tiers |
Infracost: price the change before it ships
Infracost is the only one of the three that helps you before money is spent, and for most small teams that is where the leverage is. The classic expensive mistake is not a slow leak. It is one PR that bumps an instance class, adds a NAT gateway, or turns on a managed database with a large disk, and nobody in review thinks to ask what it costs.
The CLI parses your Infracost Terraform HCL directly. It does not need your cloud credentials. It sends resource metadata (type, region, size) to Infracost’s Cloud Pricing API and gets back list prices. You need a free Infracost API key, which you get with infracost auth login locally or store as a CI secret.
Locally, two commands cover most of what you need:
# Monthly estimate for everything in this Terraform directory
infracost breakdown --path .
# Save a baseline, change the code, then see only the difference
infracost breakdown --path . --format json --out-file /tmp/infracost-base.json
infracost diff --path . --compare-to /tmp/infracost-base.json
In CI, this GitHub Actions workflow posts a cost comment on every pull request and updates the same comment on later pushes instead of spamming new ones:
# .github/workflows/infracost.yml
name: infracost
on: [pull_request]
jobs:
infracost:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
env:
TF_ROOT: infra
steps:
- name: Setup Infracost
uses: infracost/actions/setup@v3
with:
api-key: ${{ secrets.INFRACOST_API_KEY }}
- name: Checkout base branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref }}
- name: Generate baseline
run: |
infracost breakdown --path=${TF_ROOT} \
--format=json \
--out-file=/tmp/infracost-base.json
- name: Checkout PR branch
uses: actions/checkout@v4
- name: Generate diff
run: |
infracost diff --path=${TF_ROOT} \
--format=json \
--compare-to=/tmp/infracost-base.json \
--out-file=/tmp/infracost.json
- name: Post PR comment
run: |
infracost comment github --path=/tmp/infracost.json \
--repo=$GITHUB_REPOSITORY \
--github-token=${{ github.token }} \
--pull-request=${{ github.event.pull_request.number }} \
--behavior=update
Change TF_ROOT to the folder that holds your Terraform. If you have several environments in separate folders, Infracost also supports a config file listing multiple projects. Infracost also offers a GitHub and GitLab app through Infracost Cloud, which skips the YAML. Check its docs for what is included on which plan.
When cost surfaces: pre-deploy, the best possible moment. Setup: low; 30 minutes is realistic for one repo. Kubernetes: not needed. It works the same for EC2, Cloud Run, RDS or Cloud SQL. Shared and idle: not applicable, because it prices declared resources, not runtime usage. Licensing: the CLI is open source and free; Infracost Cloud (dashboards, guardrails, tagging policies, central reporting) is paid.
The blind spots matter, so I will be explicit:
- Usage-based resources show up as “depends on usage” until you fill in an
infracost-usage.ymlfile with expected requests, GB transferred, function invocations and so on. Serverless-heavy stacks need this or the estimate is mostly blank. - It only sees what is in Terraform. Anything clicked together in the console, or deployed by another tool, is invisible.
- It prices list rates. Savings Plans, reserved instances, committed use discounts and negotiated contracts are not reflected in the PR number.
- Provider coverage is AWS, Azure and Google Cloud. Cloudflare resources in your Terraform will not get a price, so keep relying on Cloudflare’s own usage notifications there.
- Region matters. Prices differ by region, so make sure the provider region in code matches where you actually deploy, for example
ap-southeast-3(Jakarta) on AWS orasia-southeast2(Jakarta) on GCP.
None of that is a reason to skip it. A PR comment that says “this adds roughly this much per month, at list price” is still the single cheapest habit in FinOps startup Indonesia teams can adopt, because it moves the cost conversation into code review where the change can still be reversed for free.
OpenCost: biaya Kubernetes per namespace, without a license
Once you run Kubernetes, the bill stops mapping to services. AWS or GCP will tell you what the nodes cost. It will not tell you that the search namespace is using a third of the cluster because someone set its memory request to 4Gi “just to be safe”. That is the gap OpenCost fills: biaya Kubernetes per namespace, per deployment and per label, from inside the cluster.
OpenCost started as the open source core contributed by the Kubecost team and is now a CNCF project with its own specification for how Kubernetes cost should be allocated. It needs Prometheus for metrics. A minimal install, following the project’s documented Helm charts:
# 1. Prometheus with the scrape config OpenCost expects
helm install prometheus --repo https://prometheus-community.github.io/helm-charts prometheus \
--namespace prometheus-system --create-namespace \
--set prometheus-pushgateway.enabled=false \
--set alertmanager.enabled=false \
-f https://raw.githubusercontent.com/opencost/opencost/develop/kubernetes/prometheus/extraScrapeConfigs.yaml
# 2. OpenCost itself
helm install opencost --repo https://opencost.github.io/opencost-helm-chart opencost \
--namespace opencost --create-namespace
# 3. Reach the API (9003) and UI (9090) from your laptop
kubectl port-forward --namespace opencost service/opencost 9003 9090
If you already run Prometheus (for example via kube-prometheus-stack), skip step 1 and point the OpenCost chart’s Prometheus settings at your existing server instead. Check the chart’s values file for the exact keys in the version you install.
With the port-forward running, this gives you the last seven days of cost per namespace, sorted from most to least expensive (needs curl and jq):
curl -sG http://localhost:9003/allocation/compute \
-d window=7d \
-d aggregate=namespace \
-d accumulate=true \
| jq -r '.data[0] | to_entries[] | "\(.value.totalCost)\t\(.key)"' \
| sort -rn
Swap aggregate=namespace for aggregate=deployment or aggregate=label:team once your workloads carry a team label. That last one is the view that ends the “whose service is this?” argument in a budget meeting.
When cost surfaces: runtime, after the fact. Setup: medium. The Helm install is quick, but you now own Prometheus retention, OpenCost upgrades and the accuracy of your labels. Kubernetes: required; this is all it does. Licensing: Apache-2.0, free.
Shared and idle cost, honestly
This is where cluster cost tools are either useful or misleading, so it deserves its own section.
- Allocation is based on the larger of request and usage. A pod that requests 2 CPU and uses 0.2 still gets charged for roughly 2 CPU. That is deliberate: reserved capacity is capacity nobody else can schedule on. It also means OpenCost often exposes over-provisioned requests rather than “real” usage.
- Idle cost (node capacity that no workload requested) shows up as a separate
__idle__line. You can leave it visible, which I recommend at first because it is often the biggest number, or spread it across workloads with theshareIdleparameter. - Shared namespaces such as
kube-system, ingress controllers and the monitoring stack can be distributed across tenants with API parameters likeshareNamespaces. The default is to show them as their own line, which is fine for a small team. - Prices are list prices unless you configure cloud billing integration. Without it, numbers are best read as relative (“search costs about three times what checkout does”), not as invoice amounts.
The OpenCost UI is intentionally simple. It is good enough for one cluster and one engineer who knows what they are looking at. It is not something you hand to finance.
Kubecost: OpenCost plus the product layer
Kubecost uses the same allocation model as OpenCost and wraps it in a product. What you get on top, depending on tier:
- A fuller UI with saved reports, drill-downs and filters that a non-engineer can actually use.
- Savings recommendations: rightsizing container requests, cluster rightsizing, abandoned workloads, unclaimed persistent volumes.
- Multi-cluster views: one place to see staging, production and that forgotten experiment cluster together.
- Cloud bill reconciliation, so allocated numbers line up more closely with what you are actually invoiced, including discounts.
- Alerts and governance features, and enterprise items such as SSO and RBAC on higher tiers.
When cost surfaces: runtime. Setup: medium at first, more if you want multi-cluster and billing reconciliation done properly. Kubernetes: required. Shared and idle: the most configurable of the three, with idle and shared-cost rules you can set in the UI instead of remembering API parameters. Licensing: proprietary, with a free tier and paid tiers.
I am deliberately not quoting Kubecost prices or tier limits. Kubecost was acquired by IBM, and its packaging has changed more than once over the past few years. Before you commit, read the current tiers and terms on Kubecost’s official pricing page, and check two things in particular: how the free tier is limited (cluster count, data retention, or features), and whether multi-cluster views are part of the tier you are considering. Also check whether your cloud provider bundles a Kubecost edition or offers native cost allocation for its managed Kubernetes service, because that can change the math entirely.
OpenCost vs Kubecost in one sentence
Pick OpenCost when one engineer needs the numbers. Pick Kubecost when several people need to act on them across several clusters, and someone will actually follow the recommendations.
Verdict
Plain VMs, managed databases, or serverless only: Infracost, and stop there. If you do not run Kubernetes, OpenCost and Kubecost have nothing to measure. Add the PR workflow above, fill in a usage file for your Lambda or Cloud Run services, and make “check the Infracost comment” part of code review. This covers a large share of the small teams reading this site.
Terraform plus a single small cluster where the team still knows what runs where: Infracost now, OpenCost later. If three engineers can name every namespace and roughly what it costs, runtime allocation does not tell you anything new yet. Revisit when that stops being true.
Kubernetes spend large enough that nobody can say which service is burning it: Infracost plus OpenCost. This is the moment cluster cost tools pay off. Install OpenCost, label workloads by team or service, and bring the per-namespace table to your 2027 budget meeting.
Several clusters, several teams, and someone whose job includes acting on cost: consider Kubecost. The recommendations and multi-cluster views earn their keep only if a person owns the follow-up. Verify the current pricing first.
Skip Kubecost if the main output would be a dashboard nobody opens. A beautiful savings report that never becomes a PR is just another subscription, and that is exactly what the Q3 review warned about.
On World Savings Day, the advice is the same as for a personal budget: you cannot save what you cannot see. For most small teams, seeing starts in the pull request, not in the cluster. Set up Infracost this weekend, before 11.11 deploys and year-end freezes, and walk into 2027 budgeting with the change history already priced.
Ditulis oleh Asti Larasati