我最后几天正在阅读和使用基于 HPA 的 Datadog 指标。在我放文件下
https://www.datadoghq.com/blog/autoscale-kubernetes-datadog/ https://kubernetes.io/docs/tasks/run-application/horizontal-pod -autoscale/
这是我的 Datadogmetric
apiVersion: datadoghq.com/v1alpha1
kind: DatadogMetric
metadata:
name: deliver-rate
namespace: beta
spec:
query: rabbitmq.queue.messages.deliver.rate{environment:production,rabbitmq_queue:enqueue.xxx.callable}.as_count()
这是我的HPA
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: test-beta2
namespace: beta
spec:
minReplicas: 1
maxReplicas: 8
behavior:
scaleDown:
stabilizationWindowSeconds: 10
policies:
- type: Pods
value: 2
periodSeconds: 2
scaleUp:
stabilizationWindowSeconds: 10
policies:
- type: Pods
value: 2
periodSeconds: 2
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: dealroom-xxx
metrics:
- type: External
external:
metric:
name: 'datadogmetric@beta:deliver-rate'
target:
type: Value
value: 200
我有两个问题
1.
当指标值高于定义的目标值时,所有工作都有效,但没有以正确的方式扩大。例如,在我将把 metricvalue/targetvalue
和适当的desiredReplicas
desiredReplicas: 4 252/200
desiredReplicas: 6 252/200
desiredReplicas: 6 252/200
desiredReplicas: 5 240/200
desiredReplicas: 6 240/200
desiredReplicas: 6 240/200
desiredReplicas: 8 240/200
为什么自动扩缩器添加的 pod 超过 2 个
behavior:
scaleDown:
stabilizationWindowSeconds: 10
policies:
- type: Pods
value: 2
periodSeconds: 2
scaleUp:
stabilizationWindowSeconds: 10
policies:
- type: Pods
value: 2
periodSeconds: 2
2.
我定期看到 datadogmetric 的验证是错误的,但同时 datadogmetric 获取了指标并显示了值
deliver-rate True False 252 beta/test-beta2 9s
这是错误信息
HPA controller was able to get the target''s current scale"},{"type":"ScalingActive","status":"False","lastTransitionTime":"2021-05-15T14:32:01Z","reason":"FailedGetExternalMetric","message":"the
HPA was unable to compute the replica count: unable to get external metric beta/datadogmetric@beta:deliver-rate/nil:
unable to fetch metrics from external metrics API: Internal error occurred:
DatadogMetric is invalid, err: Outdated result from backend, query: rabbitmq.queue.messages.deliver.rate{environment:production,rabbitmq_queue:enqueue.dealroom-php.callable}.as_count()"},{"type":"ScalingLimited","status":"True","lastTransitionTime":"2021-05-15T14:30:57Z","reason":"TooManyReplicas","message":"the
desired replica count is more than the maximum replica count"}]'
谁能帮我解决这两个问题?