kubernetes - HorizontalPodAutoscaler 基于自定义指标的缩放 - 节点池级别指标
问题描述
我目前正在尝试设置 GKE 集群并HorizontalPodAutoscaler
根据自定义指标(GPU 消耗)配置一个。我有两个节点池,我想根据每个节点的平均 GPU 消耗水平扩展它们 node_pool
。我已经像这样配置了两个相同的 HPA:
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: ner
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: ner
minReplicas: 1
maxReplicas: 10
metrics:
- type: External
external:
metric:
name: kubernetes.io|container|accelerator|duty_cycle
target:
type: AverageValue
averageValue: 60
我只替换了,scaleTargetRef
但事实证明这个指标似乎是在集群级别聚合的。我已经仔细检查过scaleTargetRef
是否正确定义。
有没有办法按container_name
or过滤指标node_pool
?任何其他建议都会很棒!
解决方案
因此,我认为您正在为您的 k8 集群寻找指标,尤其是通过container_name
or node_pool
。
您可以在 HPA 对象中使用五种类型的指标(autoscaling/v2beta2)
k explain HorizontalPodAutoscaler.spec.metrics.type --api-version=autoscaling/v2beta2
编辑更新
- 容器资源
- External # 如果指标与 Kubernetes 对象无关,请使用此选项。
- 目的
- 豆荚
- 资源
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: ner
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: ner
minReplicas: 1
maxReplicas: 10
metrics:
- type: ContainerResource
containerResource:
name: gpu
container: your-application-container
target:
type: Utilization
averageUtilization: 60
编辑更新
对于具有 Cloud Monitoring 指标的 GKP Autoscaling 部署
推荐阅读
- android - 单击回收器适配器、Kotlin、Android Studio 中的单元格时显示进度条
- javascript - Firebase Storage Nodejs 如何在控制台中显示 url Public PDF Files
- linux - 颤振运行无休止运行Gradle任务'assembleDebug'
- java - 将 C 转换为 Java
- reactjs - ReactJS cors“'Access-Control-Allow-Origin'标头包含多个值”
- django - django-celery-beat 和 DatabaseScheduler 具有设置的首次运行时间
- python - Tensorflow - 将张量扩展到 3D 的更好方法
- .net - Wix - 无法重新编译从 MSI 反转的 WXS - ICE68:操作的自定义操作类型无效
- c# - 当我停止触摸虚拟操纵杆时,是否有停止播放器的方法?
- node.js - sequelize 播种机中未决的无效价值承诺