节点的部分资源需要运行一些必要的Kubernetes系统组件和Kubernetes系统资源,使该节点可作为您的集群的一部分。因此,您的节点资源总量与节点在Kubernetes中的可分配资源之间会存在差异。节点的规格越大,在节点上部署的容器可能会越多,所以kubernetes自身需预留更多的资源。
为了保证节点的稳定性,CCE集群节点上会根据节点的规格预留一部分资源给Kubernetes的相关组件(kubelet,kube-proxy以及docker等)。
CCE对用户节点可分配的资源计算法则如下:
Allocatable = Capacity - Reserved - Eviction Threshold
即,节点上可配置值=总量-预留值-驱逐阈值。
mem_reserved_total = reserved_value_for_system + reserved_value_for_pods
- reserved_value_for_system:
− total_mem <= 8GB,reserved_value_for_system = 0MB
− 8GB < total_mem <= 16GB, reserved_value_for_system = ( (total_mem – 8GB)*1024*10% )MB
− 16GB < total_mem <= 128GB, reserved_value_for_system = ( 8GB*1024*10% + (total_mem – 16GB)*1024*6% )MB
− total_mem > 128GB, reserved_value_for_system = ( 8GB*1024*10% + 112GB*1024*6% + (total_mem – 128GB)*1024*2% )MB
- reserved_value_for_pods:
total_mem <= 2GB:
reserved_value_for_pods = total_mem *25%
total_mem > 2GB:
− 0 < pods <= 16, reserved_value_for_pods = 700 MB
− 16 < pods <= 32, reserved_value_for_pods = ( 700 + (pods - 16)*18.75 )MB
− 32 < pods <= 64, reserved_value_for_pods = ( 1024 + (pods - 32)*6.25 )MB
− 64 < pods <= 128, reserved_value_for_pods = ( 1230 + (pods - 64)*7.80 )MB
− pods > 128, reserved_value_for_pods = ( 1740 + (pods - 128)*11.20 )MB
其中:
- “total_mem”为内存总量。
- “pods”为节点的最大实例数。
- “mem_reserved_total”为总预留值。
- “reserved_value_for_system”为系统组件预留值。
- “reserved_value_for_pods”为Kubelet管理Pod所需预留值。
须知:
对于小规格节点,需根据实际使用情况调整节点的最大实例数。或者在CCE控制台创建节点时,需考虑根据节点规格自适应调整节点的最大实例数参数。
- total_cpu <= 1core,reserved_value= total_cpu *6%
- 1core < total_cpu <= 2core, reserved_value= 1core*6% + (total_cpu– 1core)*1 %
- 2core < total_cpu <= 4core, reserved_value= 1core*6% + 1core*1% + (total_cpu– 2core)*0.5%
- total_cpu > 4core, reserved_value= 1core*6% + 1core*1% + 2core*0.5% + (total_cpu– 4core)*0.25%
其中:
- “total_cpu”为CPU总量。
- “reserved_value”为预留值。
- CCE对节点预留了额外的100Mi给kubelet驱逐所用。