Skill 7.3.1

Allocate Kubernetes costs to namespaces, workloads and teams

Key Concepts

The provider bills for nodes (virtual machines), storage, load balancers and the control plane, not for pods. To allocate cost to teams, a tool must distribute node cost to the pods running on each node, then aggregate pods by namespace, label or workload. OpenCost, a Cloud Native Computing Foundation (CNCF) project, and commercial tools do this using resource prices and cluster metrics.

A pod's request reserves CPU and memory on a node, whether it uses them or not, so most allocation models charge each pod for the larger of its request and its actual usage. Charging only actual usage hides the capacity that over-requested pods block. CPU and memory are priced separately, usually by splitting the node price between them.

Some cost belongs to no single workload. Idle cost is node capacity that no pod requests. Shared costs include the control plane, system and monitoring pods and shared networking. Both must be allocated by an agreed rule, such as proportionally to each team's allocated cost, or reported as a platform cost with its own owner.