34 lines
832 B
YAML
34 lines
832 B
YAML
# 按 CPU 自动扩缩容。AI 服务多为 I/O 等待,CPU 不一定能反映负载,可改用自定义指标(并发请求数、队列长度)
|
|
apiVersion: autoscaling/v2
|
|
kind: HorizontalPodAutoscaler
|
|
metadata:
|
|
name: agent-api
|
|
spec:
|
|
scaleTargetRef:
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
name: agent-api
|
|
minReplicas: 3
|
|
maxReplicas: 10
|
|
metrics:
|
|
- type: Resource
|
|
resource:
|
|
name: cpu
|
|
target:
|
|
type: Utilization
|
|
averageUtilization: 70
|
|
behavior:
|
|
scaleDown:
|
|
stabilizationWindowSeconds: 300 # 缩容慢一点,避免抖动
|
|
---
|
|
# 节点维护(驱逐)时至少保留 2 个可用 Pod
|
|
apiVersion: policy/v1
|
|
kind: PodDisruptionBudget
|
|
metadata:
|
|
name: agent-api
|
|
spec:
|
|
minAvailable: 2
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/name: agent-api
|