Files
oam/knowledge base/kubernetes/opencost.md
2025-06-24 23:46:40 +02:00

2.4 KiB

OpenCost

Monitoring application providing real-time cost visibility and insights.

Used as base by KubeCost.

  1. TL;DR
  2. Further readings
    1. Sources

TL;DR

Setup

Requires:

  • A Prometheus instance to be available.

    Caution

    OpenCost's pods will error out and go in CrashLoopBackoff if it cannot connect to Prometheus.
    See the Helm chart values at opencost.prometheus to configure that connection.

  • The above Prometheus instance to have a scrape target configured for OpenCost.
    See OpenCost extraScrapeConfigs for Prometheus.

helm repo add 'opencost' 'https://opencost.github.io/opencost-helm-chart' && helm repo update 'opencost'
helm search repo 'opencost/opencost' --versions

helm show values --repo 'https://opencost.github.io/opencost-helm-chart' 'opencost'

helm --namespace 'opencost' upgrade --install 'opencost' 'opencost/opencost' --create-namespace
helm --namespace 'opencost' upgrade --install 'opencost' --create-namespace \
  --repo 'https://opencost.github.io/opencost-helm-chart' 'opencost' \
  --set 'opencost.prometheus.internal.namespaceName=prometheus'

helm --namespace 'opencost' uninstall 'opencost' \
&& kubectl delete namespace 'opencost'
Usage
kubectl --namespace 'opencost' port-forward 'service/opencost' '9003' '9090'
curl 'http://localhost:9003/allocation/compute?window=60m'
open 'http://localhost:9090'

Further readings

Sources