gpt4 book ai didi

kubernetes - Kubernetes Autoscaler:可以缩​​减规模时,部署是否不会停机?

转载 作者:行者123 更新时间:2023-12-02 12:10:41 25 4
gpt4 key购买 nike

在一个项目中,我正在从Kubernetes启用集群自动缩放器功能。
根据文档How does scale down work,我了解到,当给定时间使用某个节点的时间少于其容量的50%时,该节点将连同其所有 pods 一起被移除,并在需要时将其复制到其他节点中。
但是可能会发生以下问题:如果与特定部署相关的所有pod都包含在要删除的节点中,该怎么办?这意味着用户可能会因该部署的应用程序而停机。
有没有一种方法可以避免在有只包含在该节点上运行的Pod的部署中,按比例缩小操作删除一个节点?
我已经检查了文档,一种可能的(但不是很好)的解决方案是在包含应用程序here的所有Pod中添加注释,但这显然不会以最佳方式缩减集群。

最佳答案

在同一文档中:

What happens when a non-empty node is terminated? As mentioned above, all pods should be migrated elsewhere. Cluster Autoscaler does this by evicting them and tainting the node, so they aren't scheduled there again.


什么是 Eviction?:

The eviction subresource of a pod can be thought of as a kind of policy-controlled DELETE operation on the pod itself.


好的,但是如果该节点上的所有 pods 同时都被搬出怎么办?
您可以使用Pod Disruption Budget来确保最少的副本始终在工作:
什么是PDB ?:

A PDB limits the number of Pods of a replicated application that are down simultaneously from voluntary disruptions.


k8s docs中,您还可以阅读:

A PodDisruptionBudget has three fields:

A label selector .spec.selector to specify the set of pods to which it applies. This field is required.

.spec.minAvailable which is a description of the number of pods from that set that must still be available after the eviction, even in the absence of the evicted pod. minAvailable can be either an absolute number or a percentage.

.spec.maxUnavailable (available in Kubernetes 1.7 and higher) which is a description of the number of pods from that set that can be unavailable after the eviction. It can be either an absolute number or a percentage.


因此,如果使用PDB进行部署,则不应立即删除它。
但是请注意,如果节点由于其他原因(例如硬件故障)而发生故障,您仍然会遇到停机时间。如果您真的很在意高可用性,请考虑使用容器抗亲和力来确保未在一个节点上计划所有容器。

关于kubernetes - Kubernetes Autoscaler:可以缩​​减规模时,部署是否不会停机?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63421461/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com