【问题标题】:K8S - HPA without Deployment ObjectK8S - 没有部署对象的 HPA
【发布时间】:2019-08-01 01:24:03
【问题描述】:

我在玩 k8s HPA - 水平 pod 自动缩放器。事情按预期工作(如此处所述 - https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/

如果我删除部署kubectl delete deploy php-apache,部署会被删除,pod 也会被删除。但是 HPA 条目仍然存在用于部署。在没有部署对象的情况下,这个入口有什么意义?

【问题讨论】:

    标签: kubernetes


    【解决方案1】:

    从逻辑意义上讲,水平 pod 自动扩缩器是一个控制循环,用于检查其指定目标(例如部署)以查看是否已达到指标阈值。 (这实际上是通过控制器管理器和指标 API 发生的)。 HPA 是它自己的独立资源,它通过称为Scale subresource 的东西与部署进行交互。这是一种抽象,可充当 Kubernetes 可能希望自动扩展的任何未来资源(不仅仅是部署)的接口。

    Horizo​​ntal Pod Autoscaler 的规范(取自 k8s 设计文档):

    type HorizontalPodAutoscalerSpec struct {
        // reference to Scale subresource; horizontal pod autoscaler will learn the current resource
        // consumption from its status,and will set the desired number of pods by modifying its spec.
        ScaleRef SubresourceReference
        // lower limit for the number of pods that can be set by the autoscaler, default 1.
        MinReplicas *int
        // upper limit for the number of pods that can be set by the autoscaler.
        // It cannot be smaller than MinReplicas.
        MaxReplicas int
        // target average CPU utilization (represented as a percentage of requested CPU) over all the pods;
        // if not specified it defaults to the target CPU utilization at 80% of the requested resources.
        CPUUtilization *CPUTargetUtilization
    }
    

    请注意,HPA 使用 scale ref 来定位所需资源,而 Deployment 通过其选择器包含多个资源。出于灵活性原因,HPA 与特定部署分离。这意味着当您删除 Deployment 时,k8s 可以删除它通过其选择器管理的所有内容。 HPA 不由 Deployment 管理,而仅通过其自己的规范连接到它。 HPA 可以保留,等待新部署取代原来的位置,可以重新配置,也可以删除。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-16
      • 2020-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-16
      • 2021-07-12
      相关资源
      最近更新 更多