Skip to content

Kubernetes Agent

The ClusterCost agent is a minimal, efficient Go binary that runs once per cluster. It calculates real-time cost estimates without heavy dependencies.

View on GitHub

The agent runs as a single Deployment (not a DaemonSet). It scrapes cluster state, matches it with pricing data, and exposes metrics locally.

  • Core Pipeline: Informers cache cluster state (nodes, pods, namespaces).
  • Usage Data: Fetches real-time usage from the Kubernetes Metrics API.
  • Pricing: Applies offline-generated AWS pricing tables to calculate hourly costs.
  1. Scrape Loop: Every 60s, the agent snapshots the cluster state.
  2. Cost Calculation:
    • Converts CPU/Memory usage to hourly rates.
    • Allocates node costs across running pods.
    • Aggregates data by pod, namespace, workload, and label.
  3. Enrichment: Merges labels to create consistent keys for teams, services, and environments.

The agent only talks to the Kubernetes API and Metrics API.

SourceData Points
Kubernetes APINodes (instance types, capacity), Namespaces, Pods (requests, owners).
Metrics APIReal-time CPU and Memory usage per pod.
Pricing ConfigEmbedded AWS pricing tables (generated offline).

The agent exposes data strictly within the cluster.

  • Prometheus Metrics: /metrics endpoint for scraping.
  • JSON API: /api/cost/* endpoints for the local dashboard.
  • Health Checks: /healthz and /readyz for liveness probes.

Your data never leaves the cluster.

The agent performs all calculations locally. It does not make outbound calls to AWS APIs or external SaaS platforms. Pricing data is embedded in the binary.