我已向我的 HorizontalPodAutoscaler 添加了一些扩展策略,但它们并未得到应用。 scaleUp 和 scaleDown 行为将被忽略。我需要一种方法来阻止 Pod 每隔几分钟上下扩展以响应小的 CPU 峰值。理想情况下,HPA 会随着流量的增加而快速扩展,但在流量减少约 30 分钟后缓慢缩减。
我在 AWS EKS 集群上运行此程序,并且已根据 https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior 设置策略.
这可能是 EKS 或我的 K8s 版本 1.14 的限制吗?我已经运行了 kubectl api-versions 并且我的集群支持 autoscaling/v2beta2。
我的 Helm 规范是:
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "app.fullname" . }}
labels:
app: {{ template "app.name" . }}
chart: {{ template "app.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
scaleTargetRef:
apiVersion: apps/v1beta2
kind: Deployment
name: "{{ template "app.fullname" . }}-server"
minReplicas: {{ .Values.hpa.minReplicas }}
maxReplicas: {{ .Values.hpa.maxReplicas }}
metrics:
- type: Resource
resource:
name: cpu
target:
type: AverageValue
averageValue: 200m
behavior:
scaleUp:
stabilizationWindowSeconds: 300
policies:
- type: Pods
value: 1
periodSeconds: 300
scaleDown:
stabilizationWindowSeconds: 1200
policies:
- type: Pods
value: 1
periodSeconds: 300
最佳答案
正如评论中已经讨论的那样,即使启用了 autoscaling/v2beta2
,此功能也无法在版本 1.14 上运行。
Starting from v1.18 the v2beta2 API allows scaling behavior to be configured through the HPA behavior field.
最简单的方法是升级到 1.18。
关于Kubernetes 自动缩放策略不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61106063/