Debian上Kubernetes资源分配策略
一 核心机制与QoS
二 调度与拓扑控制
三 容量规划与节点资源
| 节点角色 | CPU | 内存 | 存储 | 网络 |
|---|---|---|---|---|
| 控制平面 | ≥2 vCPU | ≥4 GB | ≥50 GB SSD | ≥1 Gbps |
| 工作节点 | ≥2 vCPU | ≥4 GB | ≥50 GB SSD | ≥1 Gbps |
四 弹性扩缩与专用硬件
五 落地配置示例
apiVersion: v1
kind: Pod
metadata:
name: app
spec:
containers:
- name: app
image: nginx:1.25
resources:
requests:
cpu: "500m"
memory: "512Mi"
limits:
cpu: "1"
memory: "1Gi" # 关键负载建议 requests≈limits(内存)
apiVersion: v1
kind: Pod
metadata:
name: web
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values: ["web"]
topologyKey: kubernetes.io/hostname
containers:
- name: web
image: nginx:1.25
resources:
requests:
cpu: "200m"
memory: "256Mi"
limits:
cpu: "500m"
memory: "512Mi"
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: web-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: web
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
上述示例体现了“为调度提供依据的requests/limits”“通过反亲和性提升高可用”“以HPA匹配负载波动”的组合式策略,可直接在Debian节点上应用并根据监控反馈迭代参数。