gpt4 book ai didi

node.js - 小型 Node.js 应用程序 Pod 的 GKE CPU 不足

转载 作者:搜寻专家 更新时间:2023-10-31 23:50:01 26 4
gpt4 key购买 nike

所以在 GKE 上,我有一个 Node.js app,每个 pod 使用大约:CPU(cores): 5m, MEMORY: 100Mi

但是我只能为每个 Node 部署 1 个 pod。我使用的是 GKE n1-standard-1 集群,每个 Node 有 1 个 vCPU,3.75 GB

所以为了获得 2 个 app pod 总计 = CPU(cores): 10m, MEMORY: 200Mi, 它需要另一个完整的 +1 Node = 2 个 Node = 2 vCPU, 7.5 GB 使其工作。如果我尝试将这 2 个 pod 部署在同一个 Node 上,我会收到 insufficient CPU 错误。

我有一种感觉,我实际上应该能够在 f1-micro 的 1 个 Node (1 个 vCPU,0.6 GB)或 f1-small(1 个 vCPU,1.7 GB),我在这里过度配置,浪费了我的钱。

但我不确定为什么我似乎受到 CPU 不足 的限制。我需要更改一些配置吗?任何指导将不胜感激。


Allocatable:
cpu: 940m
ephemeral-storage: 47093746742
hugepages-2Mi: 0
memory: 2702216Ki
pods: 110
Non-terminated Pods: (7 in total)
Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits
--------- ---- ------------ ---------- --------------- -------------
default mission-worker-5cf6654687-fwmk4 100m (10%) 0 (0%) 0 (0%) 0 (0%)
default mission-worker-5cf6654687-lnwkt 100m (10%) 0 (0%) 0 (0%) 0 (0%)
kube-system fluentd-gcp-v3.1.1-5b6km 100m (10%) 1 (106%) 200Mi (7%) 500Mi (18%)
kube-system kube-dns-76dbb796c5-jgljr 260m (27%) 0 (0%) 110Mi (4%) 170Mi (6%)
kube-system kube-proxy-gke-test-cluster-pool-1-96c6d8b2-m15p 100m (10%) 0 (0%) 0 (0%) 0 (0%)
kube-system metadata-agent-nb4dp 40m (4%) 0 (0%) 50Mi (1%) 0 (0%)
kube-system prometheus-to-sd-gwlkv 1m (0%) 3m (0%) 20Mi (0%) 20Mi (0%)
Allocated resources:
(Total limits may be over 100 percent, i.e., overcommitted.)
Resource Requests Limits
-------- -------- ------
cpu 701m (74%) 1003m (106%)
memory 380Mi (14%) 690Mi (26%)
Events: <none>

最佳答案

部署后,使用kubectl describe nodes检查 Node 容量。例如:在答案底部的代码示例中:

可分配 cpu:1800m

已被 kube-system 命名空间中的 pod 使用:100m + 260m++100m + 200m + 20m = 680m

也就是说1800m - 680m = 1120m留给你使用

因此,如果您的一个或多个 pod 请求超过 1120m 的 cpu,它们将不适合此 Node

So in order to get 2 pods of app up total = CPU(cores): 10m, MEMORY: 200Mi, it requires another entire +1 node = 2 nodes = 2 vCPU, 7.5 GB to make it work. If I try to deploy those 2 pods on the same single node, I get insufficient CPU error.

如果您进行上述练习,您会找到答案。如果有足够的 cpu 供您的 pod 使用,但您仍然收到 CPU 不足的错误,请检查您是否正确设置了 cpu 请求和限制参数。参见 here

如果您执行了上述所有操作,但问题仍然存在。然后,我认为在您的情况下,可能发生的情况是您正在为您的 Node 应用程序分配 5-10m cpu,这太少了 cpu 无法分配。尝试将其增加到 50m cpu。

I have a feeling I should actually be able to run a handful of pod replicas (like 3 replicas and more) on 1 node of f1-micro (1 vCPU, 0.6 GB) or f1-small (1 vCPU, 1.7 GB), and that I am way overprovisioned here, and wasting my money.

再一次,做上面描述的练习以得出结论

Name:            e2e-test-minion-group-4lw4
[ ... lines removed for clarity ...]
Capacity:
cpu: 2
memory: 7679792Ki
pods: 110
Allocatable:
cpu: 1800m
memory: 7474992Ki
pods: 110
[ ... lines removed for clarity ...]
Non-terminated Pods: (5 in total)
Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits
--------- ---- ------------ ---------- --------------- -------------
kube-system fluentd-gcp-v1.38-28bv1 100m (5%) 0 (0%) 200Mi (2%) 200Mi (2%)
kube-system kube-dns-3297075139-61lj3 260m (13%) 0 (0%) 100Mi (1%) 170Mi (2%)
kube-system kube-proxy-e2e-test-... 100m (5%) 0 (0%) 0 (0%) 0 (0%)
kube-system monitoring-influxdb-grafana-v4-z1m12 200m (10%) 200m (10%) 600Mi (8%) 600Mi (8%)
kube-system node-problem-detector-v0.1-fj7m3 20m (1%) 200m (10%) 20Mi (0%) 100Mi (1%)
Allocated resources:
(Total limits may be over 100 percent, i.e., overcommitted.)
CPU Requests CPU Limits Memory Requests Memory Limits
------------ ---------- --------------- -------------
680m (34%) 400m (20%) 920Mi (12%) 1070Mi (14%)

关于node.js - 小型 Node.js 应用程序 Pod 的 GKE CPU 不足,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56191553/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com