【发布时间】:2021-03-10 11:34:27
【问题描述】:
我已成功安装 Prometheus 及其适配器,我想使用其中一个 pod 指标进行自动缩放
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1" | jq . |grep "pods/http_request".
"name": "pods/http_request_duration_milliseconds_sum",
"name": "pods/http_request",
"name": "pods/http_request_duration_milliseconds",
"name": "pods/http_request_duration_milliseconds_count",
"name": "pods/http_request_in_flight",
检查 api 我想使用 pods/http_request 并将其添加到我的 HPA 配置中
---
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: app
namespace: app
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: app
minReplicas: 4
maxReplicas: 8
metrics:
- type: Pods
pods:
metric:
name: http_request
target:
type: AverageValue
averageValue: 200
应用 yaml 并检查 hpa 状态后,它显示为 <unkown>
$ k apply -f app-hpa.yaml
$ k get hpa
NAME REFERENCE TARGETS
app Deployment/app 306214400/2000Mi, <unknown>/200 + 1 more...
但是当使用其他 pod 指标(例如 pods/memory_usage_bytes)时,该值会被正确检测到
有没有办法检查这个指标的正确值?以及如何为我的 hpa 配置正确添加它
参考https://www.ibm.com/support/knowledgecenter/SSBS6K_3.2.0/manage_cluster/hpa.html
【问题讨论】:
-
您好,我想问一下您通过运行 kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1" | 得到的指标是否。 |grep "pods/http_request" 是默认的,或者您已经在适配器配置映射中手动编写了它们。谢谢
标签: kubernetes horizontal-pod-autoscaling