A quick approach for cost monitoring on Kubernetes

How to get cost insights about the projects running on Kubernetes without introducing any extra components

Lorenzo Arribas
7 min readJan 17, 2021

This article presents an approach to approximate the costs a specific project/team generates on Kubernetes, based on the ratio of resources allocated to them vs. the total resources in the cluster.

Our Kubernetes cluster is deployed using AWS EKS, and we use DataDog as a monitoring solution. The screenshots and pieces of code that illustrate this article are based on those technologies, but the general principles and formulas apply to any other stack.

The problem of cost visibility on Kubernetes

We recently migrated all of Glovo’s Machine Learning services to Kubernetes. Before that, each of our services used to run in a dedicated cluster of EC2 instances (cloud VMs).

One of the results we expected to achieve with this transition was a significant cost reduction. With Kubernetes, all our projects (big and small) would be able to share the same underlying infrastructure and thus leave less room for idle resources.

One cluster per project and one replica per machine vs. A shared cluster where replicas of multiple projects share the same machines

Before the transition to Kubernetes, each team could go to the AWS Cost Explorer and see how much money each of their…

--

--

Lorenzo Arribas
Lorenzo Arribas

Written by Lorenzo Arribas

Staff Software Engineer at Glovo. I specialize in event-driven architectures and Machine Learning Operations. My website is https://larribas.me