How to reduce your cloud bills using OpenCost

Evgeny Anikiev June 12, 2025 k8s
How to reduce your cloud bills using OpenCost

In the cloud-native development era, managing cloud costs is essential for businesses. OpenCost is an open-source tool that helps reduce expenses by monitoring Kubernetes environments and optimizing resource usage. Developed by Kubecost and released in 2022 as a CNCF sandbox project, OpenCost provides detailed visibility into both current and historical Kubernetes spending, breaking down costs by nodes, persistent volumes, pods, and namespaces.

Currently, OpenCost natively works with AWS, Azure, and GCP, meaning it can automatically import and calculate the cost of resources from these clouds. However, it is also possible to connect pricing tables for Kubernetes clusters with your own provider and use OpenCost within its ecosystem

Article content

opencost

 

OpenCost key features

 

  • Real-time cost allocation: Provides detailed breakdowns by Kubernetes concepts down to the container level.
  • Dynamic asset pricing: Integrates with AWS, Azure, and GCP billing APIs and supports custom pricing for on-prem Kubernetes clusters, enabling cross-cloud cost comparison and optimization.
  • In-cluster resource allocation: Monitors costs for CPU, GPU, memory, load balancers, and persistent volumes.
  • External resource monitoring: Tracks costs for cloud provider resources like object storage, databases, and other managed services.
  • Customizable dashboards: Allows users to create and share reports based on specific cost metrics.
  • Cost-saving recommendations: Identifies overprovisioned resources and suggests optimization opportunities.
  • Trend analysis: Helps forecast future spending by analyzing historical cost trends.

 

How to Install OpenCost in your environment

OpenCost requires Prometheus for scraping metrics and data storage. The tool can be deployed in any cluster starting from Kubernetes 1.21. You can use the official Helm chart for OpenCost installation:

helm repo add opencost-charts https://opencost.github.io/opencost-helm-chart
helm repo update
helm install opencost opencost-charts/opencost --namespace opencost --create-namespace -f values.yaml

If you don’t want to enable ingress, you can use port-forwarding to access the UI:

kubectl port-forward --namespace opencost service/opencost 9003

Another option is to use kubectl cost:

kubectl cost --service-port 9003 --service-name opencost --kubecost-namespace opencost --allocation-path /allocation/compute --namespace --window 30m --show-efficiency=true

Identifying Overprovisioned Kubernetes Resources

OpenCost provides efficiency metrics for various resources. For example, pod resource efficiency is defined as the resource utilization versus the resource request over a given time window. Based on these metrics, you can identify overprovisioned resources that can be optimized.

Article content

opencost

 

Conclusion

OpenCost is a good tool for cost optimization in Kubernetes environments, providing transparent, real-time insights into cloud spending. Adopting OpenCost leads to better financial control, enhanced operational efficiency, and increased value from cloud investments.

 

 

☁️ AWS Cloud That Saves and Scales

Helping SaaS teams cut costs, speed up releases, and scale securely with DevOps done right

Uncover Bottlenecks & Savings - Free 30-Min Review