Azure Kubernetes Cluster Autoscaler - 设置扩展节点的内存阈值
Azure Kubernetes Cluster Autoscaler - set memory threshold for scaling out nodes
在我的 1 节点 AKS 中,我部署了多个作业资源 (kind:jobs),这些资源在任务完成后终止。当太多作业消耗第一个节点内存时,我启用了 Cluster Autoscaler 添加第二个节点,但是它在由于内存不足而无法创建 job/pod 后向外扩展。
在我的工作yaml中我也定义了资源内存限制和请求。
是否有可能将 Cluster Autoscaler 配置为在达到特定内存阈值(例如节点内存的 70%)时主动横向扩展,而不仅仅是在无法部署 job/pod 时?
在 Kubernetes 中,您可以找到 3 种自动缩放机制:Horizontal Pod Autoscaler, Vertical Pod Autoscaler which both can be controlled by metrics usage and Cluster Autoscaler。
根据Cluster Autoscaler Documentation:
Cluster Autoscaler is a tool that automatically adjusts the size of the Kubernetes cluster when one of the following conditions is true:
- there are pods that failed to run in the cluster due to insufficient resources.
- there are nodes in the cluster that have been underutilized for an extended period of time and their pods can be placed on other existing nodes.
在 AKS Cluster Autoscaler Documentation 中,您可以发现 CA
是 Kubernetes 组件,而不是特定于 AKS 的东西:
The cluster autoscaler is a Kubernetes component. Although the AKS cluster uses a virtual machine scale set for the nodes, don't manually enable or edit settings for scale set autoscale in the Azure portal or using the Azure CLI. Let the Kubernetes cluster autoscaler manage the required scale settings.
在 Azure Documentation - About the cluster autoscaler 中,您了解到 AKS 集群可以通过以下两种方式之一进行扩展:
The cluster autoscaler
watches for pods that can't be scheduled on nodes because of resource constraints. The cluster then automatically increases the number of nodes.
The horizontal pod autoscaler
uses the Metrics Server in a Kubernetes cluster to monitor the resource demand of pods. If an application needs more resources, the number of pods is automatically increased to meet the demand.
在 AKS
上,您可以稍微调整 Autoscaler Profile
以更改一些默认值。可以在 Using the autoscaler profile
中找到更多详细信息
我建议您阅读 Understanding Kubernetes Cluster Autoscaling 文章,其中解释了 CA
的工作原理。在 Limitations
部分下您有信息:
The cluster autoscaler doesn’t take into account actual CPU/GPU/Memory usage, just resource requests and limits. Most teams overprovision at the pod level, so in practice we see aggressive upscaling and conservative downscaling.
结论
Cluster Autoscaler
不考虑实际资源使用情况。 CA
缩小或放大可能需要几分钟时间,具体取决于云提供商。
在我的 1 节点 AKS 中,我部署了多个作业资源 (kind:jobs),这些资源在任务完成后终止。当太多作业消耗第一个节点内存时,我启用了 Cluster Autoscaler 添加第二个节点,但是它在由于内存不足而无法创建 job/pod 后向外扩展。
在我的工作yaml中我也定义了资源内存限制和请求。
是否有可能将 Cluster Autoscaler 配置为在达到特定内存阈值(例如节点内存的 70%)时主动横向扩展,而不仅仅是在无法部署 job/pod 时?
在 Kubernetes 中,您可以找到 3 种自动缩放机制:Horizontal Pod Autoscaler, Vertical Pod Autoscaler which both can be controlled by metrics usage and Cluster Autoscaler。
根据Cluster Autoscaler Documentation:
Cluster Autoscaler is a tool that automatically adjusts the size of the Kubernetes cluster when one of the following conditions is true:
- there are pods that failed to run in the cluster due to insufficient resources.
- there are nodes in the cluster that have been underutilized for an extended period of time and their pods can be placed on other existing nodes.
在 AKS Cluster Autoscaler Documentation 中,您可以发现 CA
是 Kubernetes 组件,而不是特定于 AKS 的东西:
The cluster autoscaler is a Kubernetes component. Although the AKS cluster uses a virtual machine scale set for the nodes, don't manually enable or edit settings for scale set autoscale in the Azure portal or using the Azure CLI. Let the Kubernetes cluster autoscaler manage the required scale settings.
在 Azure Documentation - About the cluster autoscaler 中,您了解到 AKS 集群可以通过以下两种方式之一进行扩展:
The
cluster autoscaler
watches for pods that can't be scheduled on nodes because of resource constraints. The cluster then automatically increases the number of nodes.The
horizontal pod autoscaler
uses the Metrics Server in a Kubernetes cluster to monitor the resource demand of pods. If an application needs more resources, the number of pods is automatically increased to meet the demand.
在 AKS
上,您可以稍微调整 Autoscaler Profile
以更改一些默认值。可以在 Using the autoscaler profile
我建议您阅读 Understanding Kubernetes Cluster Autoscaling 文章,其中解释了 CA
的工作原理。在 Limitations
部分下您有信息:
The cluster autoscaler doesn’t take into account actual CPU/GPU/Memory usage, just resource requests and limits. Most teams overprovision at the pod level, so in practice we see aggressive upscaling and conservative downscaling.
结论
Cluster Autoscaler
不考虑实际资源使用情况。 CA
缩小或放大可能需要几分钟时间,具体取决于云提供商。