本文介绍了Kubernetes Autoscaler:可以缩​​减规模时,部署是否没有停机时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个项目中,我正在从Kubernetes启用集群自动缩放器功能.

In a project, I'm enabling the cluster autoscaler functionality from Kubernetes.

根据文档:缩小规模的工作方式,我了解到,当给定时间使用某个节点的容量不足其容量的50%时,该节点将连同其所有吊舱一起被移除,并将被复制如果需要,可以在另一个节点中.

According to the documentation: How does scale down work, I understand that when a node is used for a given time less than 50% of its capacity, then it is removed, together with all of its pods, which will be replicated in a different node if needed.

但是会发生以下问题:如果与特定部署相关的所有pod都包含在要删除的节点中,该怎么办?这将意味着用户可能会因该部署的应用程序而停机.

But the following problem can happen: what if all the pods related to a specific deployment are contained in a node that is being removed? That would mean users might experience downtime for the application of this deployment.

是否有一种方法可以避免在有仅包含在该节点上运行的容器的部署的情况下按比例缩小删除该节点?

Is there a way to avoid that the scale down deletes a node whenever there is a deployment which only contains pods running on that node?

我已经检查了文档,一种可能的(但不是很好)的解决方案是在所有包含应用程序此处,但这显然不会以最佳方式缩小群集.

I have checked the documentation, and one possible (but not good) solution, is to add an annotation to all of the pods containing applications here, but this clearly would not down scale the cluster in an optimal way.

推荐答案

在同一文档中:

什么是逐出a>?:

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

Ok, but what if all pods get evicted at the same time on the node?You can use Pod Disruption Budget to make sure minimum replicas are always working:

什么是PDB?

k8s文档中,您也可以阅读:

标签选择器.spec.selector,用于指定要应用的Pod集合.此字段为必填项.

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

.spec.minAvailable,它描述了从该集合中移出的Pod数量,即使在没有移出Pod的情况下,移出后仍必须可用.minAvailable可以是绝对数字或百分比.

.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(在Kubernetes 1.7及更高版本中可用),它描述了该集合中逐出后可能不可用的Pod数量.它可以是绝对数字或百分比.

.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进行部署,则不应一次删除全部.

So if you use PDB for your deployment it should not get deleted all at once.

但是请注意,如果节点由于其他原因(例如硬件故障)而发生故障,您仍然会遇到宕机的情况.如果您真的很在意高可用性,请考虑使用Pod Antiaffinity来确保未将Pod安排在一个节点上.

But please notice that if the node fails for some other reason (e.g hardware failure), you will still experience downtime. If you really care about High Availability consider using pod antiaffinity to make sure the pods are not scheduled all on one node.

这篇关于Kubernetes Autoscaler:可以缩​​减规模时,部署是否没有停机时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 04:01