Skip to main content

Overview

A small agent runs inside your cluster, reads namespace, pod and node metrics every few minutes, and reports them to CostOptix. CostOptix turns them into cost per workload and per team, and at month end reconciles the total to your real cloud invoice. Kubernetes cost accrues live from metrics, so there is no billing lag.
Works on any cluster: managed (EKS, AKS, GKE, DigitalOcean, Linode) or self-hosted (k3s, bare metal, on-prem). The agent reads the standard Kubernetes API and metrics.k8s.io.

Workload attribution

Cost follows the owning Deployment, StatefulSet, DaemonSet or Job, not short-lived pod names.

Invoice reconciliation

Monthly bills match what you actually paid, after discounts and commitments.

What to fix first

Reliability risks and the biggest savings, ranked for you.

Dependency map

Which workloads call which, and what breaks if one goes down.

How it works

1

The agent collects metrics

A single-replica Deployment in the cost-optix namespace reads namespace, pod and node metrics and pushes a compact batch to CostOptix over TLS.
2

Pods are resolved to workloads

Each pod is mapped to its owner through OwnerReferences (pod → ReplicaSet → Deployment, or straight to a StatefulSet, DaemonSet or Job), so cost survives pod churn.
3

Cost is worked out from requests and usage

Resource-hours are priced at node rates. Every workload’s cost adds up exactly to the cluster total, with nothing dropped or counted twice. Capacity nobody requested is shown as idle.
4

Days and months are sealed

Each completed day is sealed into an append-only ledger. At month end the month closes into a bill. Sealed days and bills never change.

Requirements


Connect a cluster

Open Kubernetes and follow the guided steps. The key and command are filled in for you.
1

Name the cluster and pick where it runs

Enter a cluster ID you will recognise, such as prod-eu. Then pick where it runs: azure, aws, gcp, digitalocean, linode, k3s, bare-metal or on-prem. Cloud nodes are priced automatically from the provider’s rates.For self-hosted clusters, tell CostOptix what the hardware costs: either the total monthly cost and capacity, or your own per-vCPU-hour and per-GiB-hour rates. You can skip this and set it later. Until then the cluster uses a rough estimate.
2

Create an agent key

Click Create agent key. The key can only push cluster metrics. Copy it now, it is shown only once. If you cannot create keys, ask an admin.
3

Run the installer

Point kubectl at the cluster and run the generated command. The cluster appears as soon as the agent’s first report arrives.
Tick Map which workloads call which to add --with-connections. See Dependency map. The installer creates the cost-optix namespace, a least-privilege ServiceAccount and ClusterRole, a Secret holding the key, a ConfigMap and a single-replica Deployment, then waits for the rollout.

Prefer to apply a manifest?

The onboarding also offers a manifest option for GitOps or review. Set these values in the agent manifest and kubectl apply it:
The agent’s ClusterRole is read-only:
The apps/replicasets rule is needed for workload attribution. Without it, pods are attributed by ReplicaSet name instead of their Deployment. The policy/poddisruptionbudgets rule lets CostOptix tell you which nodes a PodDisruptionBudget would stop you draining. Without it, everything else still works and the Nodes table says PodDisruptionBudgets were not checked.

Check the install

A healthy agent logs its settings at startup and one line after the first successful push, then stays quiet. Problems are logged once when they start and once when they clear, so anything after that first push is worth reading. The agent serves /healthz (process is up) and /readyz (at least one collection succeeded and recent pushes work) on port 8090. A failing readiness probe without restarts usually means a wrong key.

The Kubernetes page

Days are counted in UTC, so a new day starts at midnight UTC.

What to fix first

The Waste & fixes tab ranks findings for you. Reliability risks come first, because an outage costs more than waste. Then come the changes that save the most money.
  • Over-provisioned means a workload asks for more CPU or memory than it uses. A safe saving.
  • Under-provisioned means it uses more than it asked for. A reliability risk, not a saving.
  • Idle is node capacity no workload has claimed. Fewer or smaller nodes is the usual fix.

What to set requests to

Expand a namespace to see Recommended requests: what each workload’s CPU and memory requests should be, per replica, with a kubectl set resources command to apply them. Values come from the p95 of each workload’s busiest daily peak over the lookback window plus 25% headroom, the same rule as the rightsizing finding. The history belongs to the workload, so a rollout does not reset it, and a workload with less than 3 days of history is not sized yet. Workloads that ask for too little are raised first, because they risk throttling or being killed for running out of memory. When a new memory request would sit above the current limit, the command raises the limit too. No command is given when one could do harm:
  • A pod with several containers. The agent reports the pod’s total, and kubectl set resources would apply it to every container, so the total has to be split by hand.
  • Jobs, bare pods and static pods, which have no template that kubectl set resources can change.
  • Workloads with less than 3 days of usage.
Agents before 2.3.0 do not report how many containers a pod has, so their commands include -c CONTAINER for you to fill in. In kube-system and other namespaces your provider manages on AKS, EKS and GKE, changes are usually reset, and the page says so.

Which node to remove

When a cluster has more nodes than it needs, the Nodes table on the Cluster tab names the nodes to remove, in order. A node is marked Remove only when both of these hold:
  • No pod on it blocks a drain. Blockers are a PodDisruptionBudget that allows no disruption, a pod marked cluster-autoscaler.kubernetes.io/safe-to-evict: "false", a pod with no controller to recreate it, and a pod using emptyDir storage, which a drain deletes.
  • Its workload pods fit on the other nodes of the same pool, with each node kept under the same growth buffer node sizing uses. A pod with a persistent volume only moves to a node in its own zone, since disks such as Azure Disk, EBS and GCE PD stay in their zone. A pod that must not share a node with its own replicas never lands on a node already running one. A pod only moves to a node its node selector, required node affinity and tolerations allow, so a node tainted for one team or pinned by label is never used for the wrong pods.
Nodes are taken emptiest first, and each step counts the pods the step before moved, so follow the order. DaemonSet pods are left out because a drain skips them. The idle capacity finding names the same nodes. Control plane nodes are never suggested. The Nodes section opens as a map, one tile per node grouped by pool, with the bar under each tile showing how much of the node pods claim. Click a node to see its cost per day, what pods claim of its CPU and memory, its drain status and blockers, and the pods running on it with today’s cost of each. Switch to Table for the list view. Agents before 2.3.0 send no per-node capacity or blocker data. On a single-pool cluster CostOptix still names nodes, splitting the pool’s capacity evenly, and asks you to upgrade before draining. On a cluster with several pools it waits for the upgrade. Agent 2.3.0 does not report volumes or anti-affinity, and agents before 2.4.0 do not report node selectors, node affinity or taints. Until you upgrade to 2.4.0, the Nodes table says which of these were not checked. Pod rightsizing, node sizing and idle capacity also appear on the Kubernetes tab of Recommendations, where savings are verified after you act.

Invoice reconciliation

Live Kubernetes cost is an estimate built from metrics and list rates. Your cloud invoice is what you actually paid. Link the two and every monthly bill is scaled to the invoice, so reservations, savings plans, spot and negotiated discounts are all reflected. On the Cluster tab, open the billing link settings and choose:
  1. Cloud account: the connected account that pays for the cluster’s nodes.
  2. How to find the nodes on the invoice:
At month close every attributed line is scaled by:
The billed lines sum to your amortised invoice exactly, to the cent. The month-close job refuses to seal a bill that does not balance. Without a link, bills use estimated rates and say so. Self-hosted clusters have no cloud invoice, so they always use the hardware cost you set. Removing a link affects future bills only.
Linking a cluster also tells the Overview that the cluster’s nodes are already inside that cloud bill, so they are not counted twice.

Nodes that also run the host agent

If some nodes also run the host agent, each linked machine’s Kubernetes share becomes its cost here, and the cluster page shows how many nodes are covered.

Teams and chargeback

Teams claim namespaces or individual workloads on the Ownership page. Each workload can belong to only one team, so totals never double count.
  • Direct cost is the sum of a team’s claimed workloads.
  • Idle cost is split across teams in proportion to their direct cost.
  • Unclaimed workloads are shown as unclaimed, never dropped.
Each month closes into a sealed, reconciled bill per team. Ownership needs Professional or above.

Dependency map

Connection mapping is optional. It adds one small pod per node (a DaemonSet) that reads the node’s connection table, so it runs as root on the node’s network. It records which workloads were connected, never what the connections carry. Turn it on during install with --with-connections, or later from Agent health on the Cluster tab. The Dependencies tab then shows which workloads call which and what each one brings down with it.
Clusters that enforce Pod Security admission need the cost-optix namespace labelled pod-security.kubernetes.io/enforce=privileged for the connection pods. The installer sets this when you use --with-connections.

Agent health and upgrades

Agent health on the Cluster tab checks that the agent is reporting, whether a newer version is out, when the agent key expires, and whether connection mapping is reporting from every node. To upgrade, run this with kubectl pointed at the cluster. It reuses the key, cluster ID and settings already in the cluster, so the cluster keeps its history:
Add a version tag after --upgrade to pin one, and --with-connections to turn on mapping at the same time. The agent runs as a single replica by design. A second replica would push duplicate metrics.

Limits

Plans count Kubernetes nodes, not clusters. The Kubernetes page shows how many nodes you are using against your limit. See Subscription Tiers.

Removing a cluster

Delete the namespace and the cluster-scoped RBAC:
The ClusterRole and ClusterRoleBinding survive a namespace delete, so remove them separately. Then delete the cluster from the Kubernetes page to remove its history from CostOptix.

Security

The agent has read-only access to cluster metadata and metrics. It never creates, changes, scales or deletes anything. It runs as a non-root user from a minimal image with no shell or package manager, and only connects out to the CostOptix API over TLS. You can restrict egress with a NetworkPolicy that allows only the CostOptix API, the API server and DNS. The optional connection mapping pods are the exception to non-root: they need root on the node’s network to read its connection table. See Security for the full platform model.