Kubernetes Requests/Limits 与 HPA 配置指南基本概念CPU 以核为单位,使用毫核标记(如 `500m` 表示 0.5 核)。内存以字节为单位,常用 `Mi/Gi`(如 `512Mi`)。`requests` 决定调度与保障下限;`limits` 约束上限并可能触发限制或 OOM。资源与探针示例(Deployment 节选)resources: requests: cpu: "500m" memory: "512Mi" limits: cpu: "1" memory: "1Gi" readinessProbe: httpGet: path: /healthz port: 8080 initialDelaySeconds: 5 periodSeconds: 10 livenessProbe: httpGet: path: /livez port: 8080 initialDelaySeconds: 10 periodSeconds: 20 HPA v2 示例(基于 CPU 利用率)apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: my-app-hpa spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: my-app minReplicas: 2 maxReplicas: 10 metrics: - type: Resource resource: name: cpu target: type: Utilization averageUtilization: 60 验证清单确认 `metrics-server` 正常工作:`kubectl get deployment -n kube-system metrics-server`。使用 `kubectl top pods` 与 HPA 状态(`kubectl describe hpa`)观察伸缩行为。

发表评论 取消回复