【问题标题】:Azure Kubernetes Cluster Autoscaler - set memory threshold for scaling out nodesAzure Kubernetes Cluster Autoscaler - 设置扩展节点的内存阈值
【发布时间】:2021-03-09 17:05:26
【问题描述】:

在我的 1 个节点 AKS 中,我部署了多个作业资源(种类:作业),这些资源在任务完成后终止。我已启用 Cluster Autoscaler 在太多作业消耗第一个节点内存时添加第二个节点,但是在由于内存不足而无法创建作业/pod 后它会横向扩展。

在我的工作 yaml 中,我还定义了资源内存限制和请求。

是否有可能将 Cluster Autoscaler 配置为在达到某个内存阈值(例如,节点内存的 70%)时主动向外扩展,而不仅仅是在它无法部署作业/pod 时?

【问题讨论】:

  • 恐怕不可能。 ClusterAutosclaer 会在以下情况下调整 Kubernetes 集群的大小: - 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. 我稍后会在回答中进一步解释。

标签: kubernetes azure-aks


【解决方案1】:

在 Kubernetes 中,您可以找到 3 种自动缩放机制:Horizontal Pod AutoscalerVertical Pod Autoscaler,它们都可以通过指标使用和Cluster Autoscaler 来控制。

根据Cluster Autoscaler Documentation

Cluster Autoscaler 是一种在满足以下条件之一时自动调整 Kubernetes 集群大小的工具:

  • 由于资源不足,集群中有 pod 运行失败。
  • 集群中存在长时间未充分利用的节点,它们的 pod 可以放置在其他现有节点上。

AKS Cluster Autoscaler Documentation 中,您会发现CA 是Kubernetes 组件,而不是特定于AKS 的东西:

集群自动扩缩器是一个 Kubernetes 组件。尽管 AKS 群集为节点使用虚拟机规模集,但请勿在 Azure 门户中或使用 Azure CLI 手动启用或编辑规模集自动缩放的设置。让 Kubernetes 集群自动扩缩器管理所需的扩缩设置。

Azure Documentation - About the cluster autoscaler 中,您了解 AKS 群集可以通过以下两种方式之一进行扩展:

cluster autoscaler 监视因资源限制而无法在节点上调度的 pod。然后集群会自动增加节点数。

horizontal pod autoscaler 使用 Kubernetes 集群中的 Metrics Server 来监控 Pod 的资源需求。如果应用程序需要更多资源,则会自动增加 pod 的数量以满足需求。

AKS 上,您可以稍微调整一下Autoscaler Profile 以更改一些默认值。更多详情请见Using the autoscaler profile

我建议您阅读 Understanding Kubernetes Cluster Autoscaling 文章,该文章解释了 CA 的工作原理。在Limitations 部分您有信息:

集群自动扩缩器不考虑实际 CPU/GPU/内存使用情况,只考虑资源请求和限制。大多数团队在 pod 级别过度配置,因此在实践中我们看到激进的升级和保守的降级。

结论

Cluster Autoscaler 不考虑实际资源使用情况。 CA 降级或升级可能需要几分钟,具体取决于云提供商。

【讨论】:

    猜你喜欢
    • 2020-01-15
    • 1970-01-01
    • 2019-08-04
    • 2022-01-12
    • 1970-01-01
    • 2021-12-30
    • 1970-01-01
    • 2017-05-15
    • 2022-07-21
    相关资源
    最近更新 更多