【问题标题】:Why isn't Keda's Horizontal Pod Autoscaling (HPA) collecting CPU/Memory metrics in AWS Elastic Kubernetes Service (EKS)?为什么 Keda 的 Horizo​​ntal Pod Autoscaling (HPA) 不收集 AWS Elastic Kubernetes Service (EKS) 中的 CPU/Memory 指标?
【发布时间】:2022-08-20 04:59:07
【问题描述】:

我遇到了这个问题并解决了它,所以这个问答就在这里,以防其他人花时间筛选 AWS、Keda 和/或 Kubernetes 的文档试图推断出这个答案

我的团队部署了 Keda,目标是根据 Redis 队列长度、CPU 利用率和内存利用率在 Kubernetes 中水平自动缩放 Pod。部署后,我们注意到在 ArgoCD 中查看的水平 pod 自动缩放器正在抛出错误:

unable to get metrics for resource memory: unable to fetch metrics from resource metrics API: the server could not find the requested resource (get pods.metrics.k8s.io)

我们看到的其他一些错误:

$ kubectl get --raw \"/apis/metrics.k8s.io/v1beta1\"
Error from server (NotFound): the server could not find the requested resource
$ kubectl top nodes
error: Metrics API not available

当然,这些错误是在达到 CPU/内存利用率阈值时 Pod 无法自动缩放的人类可见问题的补充。

尽管通过 Keda/HPA 按预期扩展了 redis 队列 pod,但仍会发生这种情况。

我们可以做些什么来确保 CPU 和内存利用率会导致按预期进行扩展?

    标签: amazon-eks horizontal-pod-autoscaling keda metrics-server


    【解决方案1】:

    事实证明,这是由以下原因引起的:

    • Keda 在后台使用metrics-server 作为 CPU/内存利用率指标;这在他们的文档中的 CPU 和内存利用率页面上没有注明,而是在他们的 Keda 指标查询页面(截至本文撰写时,https://keda.sh/docs/2.8/operate/metrics-server/)的侧边栏中注明:Note: There are 2 exceptions in querying metrics and those are cpu and memory scalers. When KEDA creates the HPA object, it uses standard cpu and memory metrics from the Kubernetes Metrics Server. If you want to query these 2 specific values, you should do it using /apis/metrics.k8s.io/v1beta1 instead of /apis/external.metrics.k8s.io/v1beta1
    • AWS EKS 默认不安装 metrics-server。作为参考,在撰写本文时,AWS 文档阅读“在 Amazon EKS 中,默认情况下未安装 Metrics Server”。 (https://aws.amazon.com/premiumsupport/knowledge-center/eks-metrics-server/)

    为了解决这个问题,我们通过其 Helm 图表将metrics-server 安装到我们的集群中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-02-05
      • 2018-02-18
      • 2019-06-28
      • 1970-01-01
      • 2019-05-20
      • 1970-01-01
      • 2019-06-25
      相关资源
      最近更新 更多