Terraform module to deploy OpenCost (cloud cost monitoring) on Kubernetes using Helm.
OpenCost provides cost monitoring and allocation with carbon footprint tracking. It integrates with Prometheus for cost visibility across your Kubernetes clusters.
- Cost Visibility: Track infrastructure costs by workload, namespace, and pod
- Carbon Tracking: Monitor carbon emissions of your infrastructure
- Prometheus Integration: Uses Prometheus metrics for cost calculations
- Multi-cluster Support: Manage costs across multiple clusters
module "opencost" {
source = "fabiocicerchia/opencost/helm"
release_name = "opencost-charts"
namespace = "opencost"
}| Name | Description | Type | Default | Required |
|---|---|---|---|---|
release_name |
Helm release name for OpenCost | string |
"opencost-charts" |
no |
namespace |
Kubernetes namespace for OpenCost | string |
"opencost" |
no |
chart_version |
Helm chart version (empty string for latest) | string |
"" |
no |
values |
Helm values for OpenCost deployment | any |
{} |
no |
| Name | Description |
|---|---|
namespace |
Kubernetes namespace where OpenCost is deployed |
release_name |
Helm release name of OpenCost |
chart_version |
Chart version of OpenCost deployment |
- Terraform >= 1.0 or OpenTofu >= 1.6
- Helm >= 2.0
- Kubernetes v1.24+
- kubectl configured to access your cluster
Important: OpenCost requires Prometheus to function properly. Ensure you have Prometheus deployed in your cluster and configure OpenCost to connect to it via the values configuration.
module "opencost" {
source = "fabiocicerchia/opencost/helm"
namespace = "opencost"
}module "opencost" {
source = "fabiocicerchia/opencost/helm"
values = {
prometheus = {
server = "http://prometheus-server.monitoring.svc.cluster.local:80"
}
}
}module "opencost" {
source = "fabiocicerchia/opencost/helm"
chart_version = "1.15.0"
}Port-forward to access OpenCost UI:
kubectl port-forward -n opencost svc/opencost 9090:9090Visit http://localhost:9090 to view cost data.
kubectl port-forward -n opencost svc/opencost 9090:9090
curl http://localhost:9090/healthzMIT