Visible cost! A tool to realize k8s resource cost monitoring visualization

RancherLabs 2020-11-11 11:50:43
visible cost tool realize k8s

This article is from Rancher Labs

Pay attention to our , First time to acquire technology dry goods

Calculation Kubernetes The complexity of the cost

use Kubernetes And a service-based architecture can bring many benefits to the enterprise , For example, teams can migrate faster and applications can be expanded more easily . But this shift also brings some complexity , For example, the visibility of cloud costs . This is because applications and their resource requirements are often dynamic , And the team shares core resources without transparent pricing tied to the workload . Besides , Be fully aware of Kubernetes The advantages of the enterprise will usually run resources on different types of machines , It even runs on multiple cloud providers .

In this paper , We'll learn about how to do business for showback/chargeback The best practice and different implementation methods of project cost monitoring , And how to empower users to take action on this information . We will first understand Kubecost, It provides an open source way to ensure that across all Kubernetes Consistent and accurate visibility of the workload .

Let's learn more about best practices , To accurately allocate and monitor Kubernetes The cost of the workload and related hosting services .

Cost allocation

The precise allocation of resource costs is in Kubernetes The first step in creating cost visibility and efficient cost utilization in the environment .

To do this correctly , You need to allocate costs through a single container at the workload level . When the workload allocation is complete , By aggregating different sets of workloads , Costs can be properly allocated to teams 、 Departments and even individual developers . The cost allocation framework at the workload level is as follows :

Let's take this framework apart a little bit .

The average amount of resources consumed by Kubernetes scheduler For computing or provided by cloud providers , It depends on the specific resource being measured . We suggest that according to request and usage To calculate the maximum of memory and CPU Distribute . In this way, it can be reflected by Kubernetes scheduler The amount of resources reserved by itself . On the other hand , Resources such as load balancers and persistent volumes are strictly based on the amount provided by the provider .

Kubernetes API You can directly calculate the time period of resource consumption . It's up to resources ( Such as memory 、CPU and GPU etc. ) stay Running The time taken by the state determines . To get data to the cloud chargeback It's accurate enough , We suggest that the team combine this data with specific cloud resources provided by cloud providers ( Such as node ) The time taken to coordinate , bring into correspondence with . We'll talk more about this later .

Resource prices are determined by looking at the cost of each particular resource in the environment . for example ,us-east-1 AWS In the region m5.xlarge spot Example of CPU The hourly price is different from the on-demand price of the same instance .

Using this framework, costs can be allocated appropriately between workloads , Then they can pass through any Kubernetes Concept ( Such as namespace 、 label 、 Notes or controller) Easy aggregation .

Kubernetes Cost monitoring

adopt Kubernetes Concept ( Such as pod or controller) Allocated costs , You can start mapping expenditures accurately to any internal business level , Like a team 、 product 、 Department or cost center . The usual way for enterprises is through Kubernetes Namespace to divide the team workload , Others may use Kubernetes Tags or comments to identify which team the workload belongs to .

In different applications 、 Another key factor in cost monitoring between teams, etc. is to determine who should pay for idle capacity . Specifically, it refers to the unused cluster resources that are still being charged to the enterprise . Usually , These costs are either charged to the central infrastructure cost center , Or to the application team on a pro rata basis . Allocate these costs to the team responsible for supply decisions , Adjust incentives to have an efficient scale cluster , So it has a positive effect .

Check the cloud Bill

Kubernetes Provides a lot of real-time data . This gives developers direct access to cost metrics . Although these real-time data are usually accurate , But it may not be completely consistent with the billing data of the cloud provider . for example , In determining AWS spot The hourly rate of the node , Users need to wait Spot Data sources or costs and use reports to determine accurate rates . For billing and charging purposes , You should check the data against the actual Bill .

adopt Kubecost Get better visibility and Governance

We've learned how to look at data to calculate Kubernetes The cost of the workload . Another way is to use Kubecost, This is a cost and capacity management solution based on open source , Provide for the whole of Kubernetes Visibility of the environment .Kubecost by Kubernetes Workloads and the associated management services they consume ( Such as S3 or RDS) Provide cost visibility and insight . This product collects Kubernetes Real-time data , And check with your cloud billing data , To reflect the actual price you paid .

With the image Kubecost Such a solution , You can empower application engineers to make smart real-time decisions , It's an immediate and long-term practice , To optimize and govern cloud spending . This includes cost optimization without compromising performance 、 The implementation of Kubernetes Budget and alert 、showback/chargeback Projects are even cost based automation .

Kubecost The Community Edition is free to use , And it has all the above functions . You can Rancher Find... In the app store Kubecost Helm chart, Deploy easily . With the help of Rancher, You can get Kubernetes Cluster visualization and excellent control experience , meanwhile Kubecost Provides you with a direct view of spending and how to optimize costs . They work together for use Kubernetes The team provided a complete cost management solution .


  1. 【计算机网络 12(1),尚学堂马士兵Java视频教程
  2. 【程序猿历程,史上最全的Java面试题集锦在这里
  3. 【程序猿历程(1),Javaweb视频教程百度云
  4. Notes on MySQL 45 lectures (1-7)
  5. [computer network 12 (1), Shang Xuetang Ma soldier java video tutorial
  6. The most complete collection of Java interview questions in history is here
  7. [process of program ape (1), JavaWeb video tutorial, baidu cloud
  8. Notes on MySQL 45 lectures (1-7)
  9. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  10. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  11. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  12. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  13. 【递归,Java传智播客笔记
  14. [recursion, Java intelligence podcast notes
  15. [adhere to painting for 386 days] the beginning of spring of 24 solar terms
  16. K8S系列第八篇(Service、EndPoints以及高可用kubeadm部署)
  17. K8s Series Part 8 (service, endpoints and high availability kubeadm deployment)
  18. 【重识 HTML (3),350道Java面试真题分享
  19. 【重识 HTML (2),Java并发编程必会的多线程你竟然还不会
  20. 【重识 HTML (1),二本Java小菜鸟4面字节跳动被秒成渣渣
  21. [re recognize HTML (3) and share 350 real Java interview questions
  22. [re recognize HTML (2). Multithreading is a must for Java Concurrent Programming. How dare you not
  23. [re recognize HTML (1), two Java rookies' 4-sided bytes beat and become slag in seconds
  24. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  25. RPC 1: how to develop RPC framework from scratch
  26. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  27. RPC 1: how to develop RPC framework from scratch
  28. 一次性捋清楚吧,对乱糟糟的,Spring事务扩展机制
  29. 一文彻底弄懂如何选择抽象类还是接口,连续四年百度Java岗必问面试题
  30. Redis常用命令
  31. 一双拖鞋引发的血案,狂神说Java系列笔记
  32. 一、mysql基础安装
  33. 一位程序员的独白:尽管我一生坎坷,Java框架面试基础
  34. Clear it all at once. For the messy, spring transaction extension mechanism
  35. A thorough understanding of how to choose abstract classes or interfaces, baidu Java post must ask interview questions for four consecutive years
  36. Redis common commands
  37. A pair of slippers triggered the murder, crazy God said java series notes
  38. 1、 MySQL basic installation
  39. Monologue of a programmer: despite my ups and downs in my life, Java framework is the foundation of interview
  40. 【大厂面试】三面三问Spring循环依赖,请一定要把这篇看完(建议收藏)
  41. 一线互联网企业中,springboot入门项目
  42. 一篇文带你入门SSM框架Spring开发,帮你快速拿Offer
  43. 【面试资料】Java全集、微服务、大数据、数据结构与算法、机器学习知识最全总结,283页pdf
  44. 【leetcode刷题】24.数组中重复的数字——Java版
  45. 【leetcode刷题】23.对称二叉树——Java版
  46. 【leetcode刷题】22.二叉树的中序遍历——Java版
  47. 【leetcode刷题】21.三数之和——Java版
  48. 【leetcode刷题】20.最长回文子串——Java版
  49. 【leetcode刷题】19.回文链表——Java版
  50. 【leetcode刷题】18.反转链表——Java版
  51. 【leetcode刷题】17.相交链表——Java&python版
  52. 【leetcode刷题】16.环形链表——Java版
  53. 【leetcode刷题】15.汉明距离——Java版
  54. 【leetcode刷题】14.找到所有数组中消失的数字——Java版
  55. 【leetcode刷题】13.比特位计数——Java版
  56. oracle控制用户权限命令
  57. 三年Java开发,继阿里,鲁班二期Java架构师
  58. Oracle必须要启动的服务
  59. 万字长文!深入剖析HashMap,Java基础笔试题大全带答案
  60. 一问Kafka就心慌?我却凭着这份,图灵学院vip课程百度云