Kubernetes Vertical Pod Autoscaler 中倒转 Pod 重建顺序

huangapple go评论56阅读模式
英文:

reversing the order of pod recreation in Kubernetes Vertical Pod Autoscaler

问题

由于我的集群资源有限,我将min_replica选项设置为1,以尝试使用VPA来自动调整我的部署服务。到目前为止,我看到的VPA工作流程是首先删除现有的Pod,然后重新创建Pod。这种方法会导致我的服务停机。我希望VPA首先创建新的Pod,然后再删除旧的Pod,与部署的滚动更新完全相似。在我的情况下,是否有选项或技巧可以颠倒流程以满足我的需求?

英文:

I am trying to use VPA for autoscaling my deployed services. Due to limitation in resources in my cluster I set the min_replica option to 1. The workflow of VPA that have seen so far is that it first deletes the existing pod and then re-create the pod. This approach will cause a downtime to my services. What I want is that the VPA first create the new pod and then deletes the old pod, completely similar to the rolling updates for deployments. Is there an option or hack to reverse the flow to the desired order in my case?

答案1

得分: 1

这可以通过使用Python脚本或使用IAC管道来实现,您可以获取Kubernetes集群的指标,每当这些指标超过某个阈值时,触发此Python代码以创建具有所需资源的新Pod并关闭旧Pod。有关Kubernetes的Python插件的更多信息,请参阅此GitHub链接。

也可以使用Ansible执行此操作。当阈值超过某个限制时,可以触发您的Ansible Playbook,您可以指定需要创建的Pod的新大小。有关更多信息,请参阅官方Ansible文档。然而,这两种方法都需要手动分析以选择所需的Pod大小以进行扩展。因此,如果不想使用垂直扩展,可以选择水平扩展。

注意: 信息来源于官方Ansible和GitHub页面,帖子中引用了URL。

英文:

This can be achieved by using python script or by using an IAC pipeline, you can get the metrics of the kubernetes cluster and whenever these metrics exceed a certain threshold, trigger this python code for creating new pod with the required resources and shutdown the old pod. Follow this github link for more info on python plugin for kubernetes.

Ansible can also be used for performing this operation. This can be achieved by triggering your ansible playbook whenever the threshold breaches a certain limit and you can specify the new sizes of the pods that need to be created. Follow this official ansible document for more information. However both these procedures involve manual analysis for selecting the desired pod size for scaling. So if you don’t want to use vertical scaling you can go for horizontal scaling.

Note: The information is gathered from official Ansible and github pages and the urls are referred to in the post.

huangapple
  • 本文由 发表于 2023年2月19日 02:48:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/75495624.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定