zl程序教程

您现在的位置是:首页 >  后端

当前栏目

Kubernetes capacity planning: How to rightsize the requests of your cluster

Kubernetes to The of How your requests cluster
2023-09-14 09:15:17 时间

https://sysdig.com/blog/kubernetes-capacity-planning/

Kubernetes capacity planning is one of the main challenges that infrastructure engineers have to face, as understanding Kubernetes limits and requests is not an easy thing.

You might be reserving way more resources than you need to ensure your containers don’t run out of memory, or are CPU throttled. If you are in this situation, you’re going to be charged for those resources even if they aren’t being used, and it will also make deployments more difficult to schedule. That’s why Kubernetes capacity planning is always a balance between the stability and reliability of the cluster, and the correct use of the resources.

您可能会保留比所需更多的资源,以确保您的容器不会耗尽内存,或者 CPU 受到限制。如果您处于这种情况,即使这些资源没有被使用,您也会为这些资源付费,而且这也会使部署更难以安排。这就是为什么 Kubernetes 容量规划总是在集群的稳定性和可靠性以及资源的正确使用之间取得平衡。 

In this article, you’ll learn how to identify unused resources and how to rightsize the capacity of your cluster.

Don’t be a greedy developer


There are situations where a container requests more resources than it needs. If it’s just a container, it may not have a critical impact on the invoice from your cloud provider. But if this happens in all the containers, you’ll have several extra costs in your invoices in a large cluster.

Not to mention that if pods are too big, you may spend extra effort debugging scheduling issues. After all, it’s harder for Kubernetes to schedule bigger Pods following your priorities.

更不用说如果 pod 太大,您可能会花费额外的精力来调试调度问题。毕竟,Kubernetes 很难按照您的优先级安排更大的 Pod。 

Two open-source tools will help you with Kubernetes capacity planning:

  • kube-state-metrics: An add-on agent to generate and expose cluster-level metrics.
  • CAdvisor: A resource usage analyzer for containers.

Diagram showing some containers being analyzed by Kube-state-metrics and CAdvisor

With these tools running in your cluster, you’ll be able to avoid resource underuse and rightsize the requests for your cluster. 

通过在集群中运行这些工具,您将能够避免资源未充分利用并调整集群请求的大小。