topfans/k8s/helm/topfans/templates/hpa/gateway.yaml
2026-07-06 13:26:46 +08:00

36 lines
1.0 KiB
YAML

# Gateway HPA — 流量入口, 流量波动大
{{- $svc := .Values.services.gateway -}}
{{- if and $svc.enabled $svc.hpa.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "topfans.fullname" . }}-gateway
namespace: {{ .Values.namespace.name | default "topfans" }}
labels:
{{- include "topfans.labels" . | nindent 4 }}
app.kubernetes.io/component: gateway
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "topfans.fullname" . }}-gateway
minReplicas: {{ $svc.hpa.minReplicas | default 2 }}
maxReplicas: {{ $svc.hpa.maxReplicas | default 10 }}
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ $svc.hpa.targetCPU | default 60 }}
behavior:
scaleDown:
stabilizationWindowSeconds: 300 # 5 min 内不连续降
scaleUp:
stabilizationWindowSeconds: 30
policies:
- type: Percent
value: 100
periodSeconds: 60
{{- end }}