我在 HorizontalPodAutoscaler 中添加了一些扩展策略,但它们没有被应用。scaleUp和scaleDown行为被忽略。我需要一种方法来阻止 Pod 每隔几分钟就扩大和缩小一次以响应小的 CPU 峰值。理想情况下,HPA 会迅速扩大以响应更多流量,但在减少约 30 分钟的流量后缓慢缩小。
我在 AWS EKS 集群上运行它,我已经根据https://kubernetes.io/docs/tasks/run-application/horizo ntal-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