由于403错误,HPA无法获取指标 [英] HPA cannot get metrics due to 403 errors

查看:15
本文介绍了由于403错误,HPA无法获取指标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在HPA内部使用了以下指标

apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
  name: app-svc-hpa
  namespace: default
spec:
  scaleTargetRef:
    apiVersion: extensions/v1beta1
    kind: Deployment
    name: app-svc
  minReplicas: 1
  maxReplicas: 1000
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 50
  - type: Pods
    pods:
      metric:
        name: packets-per-second
      target:
        type: AverageValue
        averageValue: 1k

但HPA无法获取指标

Warning FailedGetPodsMetric 14s (x6 over 1m) horizontal-pod-autoscaler unable to get metric packets-per-second: unable to fetch metrics from custom metrics API: the server could not find the descriptor for metric custom.googleapis.com/packets-per-second: googleapi: Error 403: Permission monitoring.metricDescriptors.get denied (or the resource may not exist)., forbidden

我在专用节点池上运行Pod,并且每个节点都在一个服务帐户下运行。

服务帐户确实具有这些IAM角色

监控视频, 监控指标编写器

不确定如何修复此错误。我们非常感谢您的任何指点。谢谢。

推荐答案

我有一个启用了workload identity的群集。显然,当集群启用了工作负载标识时,指标获取失败。

1)我必须安装自定义堆栈驱动程序适配器并创建David Kruk在其评论中指出的自定义指标

2)我必须在自定义堆栈驱动程序适配器部署Pod规范中添加hostNetwork:true。CSA的GitHub存储库中提到该问题here

使用这两个更新,自动定标器可按预期工作。

这篇关于由于403错误,HPA无法获取指标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆