Docs/CloudNative/Kubernetes/Base/k8s资源限制.md
2022-10-18 16:59:37 +08:00

55 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

requests: 保底的资源要求
limits资源上限
包括以下资源
cpu
memory
Ephemeral storage 【Ephemeral短暂的】
extended-resouce如nvidia.com/gpu
pod Qos 服务质量
Guaranteed 高保障request==limit
Burstable弹性 cpu/memory request与limit不相等
bestEffort尽力而为。所有资源的request与limit都不填
k8s是使用隐性 Qos
不同的Qos调度不同
1、调度器会使用request进行调度
cpu按照该request划分权重
--cpu-manager-policy=staticGuaranteed整数会绑核
memory按Qos的OOMScore得分越高在node内存溢出以后会优先剔除
Guaranteed -998
Burstable 2-999
bestEffort 1000
Eviction驱逐
优先驱逐bestEffort
Kubelet - CPUManager
ResoureQuota【quota限制】
限制每个namespace 的资源用量
限制demo-ns namespace下非BestEffort Qos的Quota
cpu只能使用1000个
memory只能使用200Gi
pod只能创建10个
当Quota使用超过后禁止创建
apiVersion: v1
kind: ResourceQuota
metadata:
name: demo-quota
namespace: demo-ns
spec:
hard:
cpu: "1000"
memory: 200Gi
pods: "10"
scopeSelector: # 可以不填
matchExpressions
- operator: Exists
scopeName: NotBestEffort