Here's every edge case I found
📰 Reddit r/devops
Learn how to calculate Kubernetes pod costs from scratch using Python and Prometheus metrics
Action Steps
- Build a Python script to pull metrics from kube-state-metrics
- Configure cAdvisor and node-exporter to collect node-level metrics
- Use the AWS pricing APIs to get the latest pricing information
- Apply the cost calculation math to the raw Prometheus metrics
- Test and validate the cost calculations against Kubecost or OpenCost
Who Needs to Know This
DevOps engineers and developers can benefit from understanding the implementation details of Kubecost to optimize their Kubernetes costs
Key Insight
💡 Understanding the implementation details of Kubecost can help optimize Kubernetes costs
Share This
Calculate Kubernetes pod costs from scratch using Python and Prometheus metrics 💡
Key Takeaways
Learn how to calculate Kubernetes pod costs from scratch using Python and Prometheus metrics
Full Article
Spent the last several months going down a rabbit hole: I wanted to understand how Kubecost actually knows what a pod costs. Not the high-level answer — the actual implementation. So I built it myself from scratch. 1,700 lines of Python pulling directly from kube-state-metrics, cAdvisor, node-exporter, and the AWS pricing APIs. No Kubecost. No OpenCost as a dependency. Just the math applied directly to raw Prometheus metrics. Then I extended OpenCo
DeepCamp AI