基于其他POD HealthCheck的水平自动缩放

发布于 2025-01-25 10:33:04 字数 202 浏览 4 评论 0 原文

当其他POD掉落时,是否可以将POD缩放到0副本?我熟悉水平自动缩放概念的基础知识,但是据我了解,它仅在需要资源时就可以向上或向下缩放豆荚(CPU,CPU,内存)更改。 我的CI管道遵循绿色/蓝色模式,因此,当新版本部署了新版本时,第二个应用程序将缩放到0副本,而其他属于同一环境的POD则在浪费资源上。您是否知道如何使用Kubernetes或Helm功能来解决它​​?

谢谢

Is it possible to scale down a pod to 0 replicas when other pod is down?I'm familiar with the basics of the Horizontal Auto-Scaling concept, but as I understand it scales pod up or down only when demands for resources (CPU, memory) changes.
My CI pipeline follows a green/blue pattern, so when the new version of the application is being deployed the second one is scaled down to 0 replicas, leaving other pods belonging to the same environment up wasting resources. Do you have any idea how to solve it using kubernetes or helm features?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冰雪之触 2025-02-01 10:33:04

如果您有一个 ci 管道,则可以在部署蓝绿色之前运行kubectl命令并缩小部署的扩展,以免使用任何资源浪费。

但是,是的,您可以根据自定义指标扩展上/下部署或应用程序。

我建议您检查云本地项目 keda https://keda.sh/

keda

Keda是基于Kubernetes的事件驱动的Autoscaler。与Keda一起,您可以
根据数字,驱动Kubernetes中任何容器的缩放
需要处理的事件。

示例

apiVersion: keda.k8s.io/v1alpha1
kind: ScaledObject
metadata:
  name: {scaled-object-name}
spec:
  scaleTargetRef:
    deploymentName: {deployment-name} # must be in the same namespace as the ScaledObject
    containerName: {container-name}  #Optional. Default: deployment.spec.template.spec.containers[0]
  pollingInterval: 30  # Optional. Default: 30 seconds
  cooldownPeriod:  300 # Optional. Default: 300 seconds
  minReplicaCount: 0   # Optional. Default: 0
  maxReplicaCount: 100 # Optional. Default: 100
  triggers:
  # {list of triggers to activate the deployment}

比例对象参考:

If you have a CI pipeline you can just run the kubectl command and scale down the deployment before deploying the blue-green this way no resource wasting will be there.

However yes, you can scale UP/DOWN the deployment or application based on the custom metrics.

i would recommend you checking out Cloud-native project Keda : https://keda.sh/

Keda:

KEDA is a Kubernetes-based Event Driven Autoscaler. With KEDA, you can
drive the scaling of any container in Kubernetes based on the number
of events needing to be processed.

Example

apiVersion: keda.k8s.io/v1alpha1
kind: ScaledObject
metadata:
  name: {scaled-object-name}
spec:
  scaleTargetRef:
    deploymentName: {deployment-name} # must be in the same namespace as the ScaledObject
    containerName: {container-name}  #Optional. Default: deployment.spec.template.spec.containers[0]
  pollingInterval: 30  # Optional. Default: 30 seconds
  cooldownPeriod:  300 # Optional. Default: 300 seconds
  minReplicaCount: 0   # Optional. Default: 0
  maxReplicaCount: 100 # Optional. Default: 100
  triggers:
  # {list of triggers to activate the deployment}

Scale object ref : https://keda.sh/docs/1.4/concepts/scaling-deployments/#scaledobject-spec

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文