Skip to content

Latest commit

 

History

History
114 lines (79 loc) · 2.73 KB

File metadata and controls

114 lines (79 loc) · 2.73 KB

Terraform Module for OpenCost

Terraform module to deploy OpenCost (cloud cost monitoring) on Kubernetes using Helm.

Overview

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

Quick Start

module "opencost" {
  source = "fabiocicerchia/opencost/helm"

  release_name    = "opencost-charts"
  namespace       = "opencost"
}

Inputs

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

Outputs

Name Description
namespace Kubernetes namespace where OpenCost is deployed
release_name Helm release name of OpenCost
chart_version Chart version of OpenCost deployment

Requirements

  • Terraform >= 1.0 or OpenTofu >= 1.6
  • Helm >= 2.0
  • Kubernetes v1.24+
  • kubectl configured to access your cluster

Dependencies

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.

Usage

Basic Deployment

module "opencost" {
  source = "fabiocicerchia/opencost/helm"

  namespace       = "opencost"
}

With Custom Prometheus Endpoint

module "opencost" {
  source = "fabiocicerchia/opencost/helm"

  values = {
    prometheus = {
      server = "http://prometheus-server.monitoring.svc.cluster.local:80"
    }
  }
}

Pin Chart Version

module "opencost" {
  source = "fabiocicerchia/opencost/helm"

  chart_version   = "1.15.0"
}

Access OpenCost

Port-forward to access OpenCost UI:

kubectl port-forward -n opencost svc/opencost 9090:9090

Visit http://localhost:9090 to view cost data.

Verify API Health

kubectl port-forward -n opencost svc/opencost 9090:9090
curl http://localhost:9090/healthz

Resources

License

MIT