单个GKE kubernetes节点集群

时间:2019-12-28 05:12:26

标签: docker kubernetes google-cloud-platform google-kubernetes-engine

当我这样做的时候:

function getLovePercentage(name, love){
	name = name.toLowerCase().replace(/[^a-z]/g, '');
	love = love.toLowerCase().replace(/[^a-z]/g, '');;
	
	var nameASCIISum = 0;
	var loveASCIISum = 0;
	for(var i = 0; i < Math.min(name.length, love.length); i++){
		nameASCIISum += name.charCodeAt(i) - "a".charCodeAt(0);
		loveASCIISum += love.charCodeAt(i) - "a".charCodeAt(0);
	}
	
	if(nameASCIISum == 0 || loveASCIISum == 0) return 0;
	
	if(nameASCIISum > loveASCIISum) return nameASCIISum / loveASCIISum % 1 * 100;
	return nameASCIISum / loveASCIISum * 100;
}

console.log(getLovePercentage("cat", "mice"));
console.log(getLovePercentage("mice", "cat"));
console.log("------------");
console.log("And again...");
console.log("------------");
console.log(getLovePercentage("cat", "mice"));
console.log(getLovePercentage("mice", "cat"));

enter image description here

集群单节点大小:4个vCPU和16 GB内存

在Kubernetes集群操作日志中找到

enter image description here

但是CPU利用率为24%,如命令输出中所示,这是我为什么收到此错误的原因。

enter image description here

上图显示节点使用率最大为1.5 vCPU。

我的一些Pod也不断增加内存,并且在大约24小时后达到内存限制并由于设置了资源限制而自动重启。 enter image description here

问题:

如果kubectl显示CPU使用率是24%,但是为什么我在日志中发现CPU不足的错误?

1 个答案:

答案 0 :(得分:1)

您收到的错误消息是因为群集中没有可分配CPU足以满足pod的cpu请求需求的节点

k8s调度程序查看节点的可分配cpu减去请求的总cpu,以确定是否有足够的cpu来添加新的pod。

请注意,可分配或请求的cpu与节点上实际使用的cpu数量无关。调度程序不会查看实际的节点cpu使用情况,因此设置准确的资源请求很重要。您的集装箱中仅使用50m cpu,请不要将请求设置为200m,否则您将浪费很多资源。

根据您提供的信息,您的cou请求可能太高了