gpt4 book ai didi

库伯内斯。如果请求大小大于 pod 的 RAM 会怎样?

转载 作者:行者123 更新时间:2023-12-05 05:37:46 25 4
gpt4 key购买 nike

我不明白复制在 Kubernetes 中是如何工作的。

我理解不同节点上的两个副本将为应用程序提供容错能力,但我不明白这一点:

假设为应用程序提供了以下资源:

---
apiVersion: v1
kind: Pod
metadata:
name: frontend
spec:
containers:
- name: app
image: images.my-company.example/app:v4
resources:
requests:
memory: "1G"
cpu: "1"
limits:
memory: "1G"
cpu: "1"

应用程序有两个副本。因此,总共有 2 个 CPU 和 2G RAM 可供应用程序使用。

但是如果应用程序收到大小为 1.75G 的请求会怎样?毕竟,一个副本只有 1G RAM 可用。请求会分布在所有副本中吗?

对 Harsh Manvar 的回答

你是不是误会了?

您所解释的并不完全正确。

这是四个副本的真实工作部署:

$ kubectl get deployment dev-phd-graphql-server-01-master-deployment
NAME READY UP-TO-DATE AVAILABLE AGE
dev-phd-graphql-server-01-master-deployment 4/4 4 4 6d15h
$ kubectl describe deployment dev-phd-graphql-server-01-master-deployment
...
Limits:
cpu: 2
memory: 4G
Requests:
cpu: 2
memory: 4G
...

最佳答案

不,它不会被分发,一个副本将简单地开始,另一个将保持在pending状态。

如果您将描述挂起的 POD(副本),它会显示此错误:

0/1 nodes available: insufficient cpu, insufficient memory

kubectl describe pod POD-name

K8s 将检查请求的资源

requests:
memory: "1G"
cpu: "1"

如果提到可用的最小请求资源,它将部署副本,其他副本将进入挂起状态。

更新

But what happens if the application receives a request with a size of1.75G? After all, only 1G RAM is available in one replica.

requests:
memory: "1G"
cpu: "1"
limits:
memory: "1G"
cpu: "1"

如果您设置了 1 GB 的请求并且应用程序开始使用 1.75 GB,它将由于达到限制而终止或重新启动 POD。

但是在某些情况下,如果 Node 有可用内存,容器可能会超出限制。

A Container can exceed its memory request if the Node has memoryavailable. But a Container is not allowed to use more than its memorylimit. If a Container allocates more memory than its limit, theContainer becomes a candidate for termination. If the Containercontinues to consume memory beyond its limit, the Container isterminated. If a terminated Container can be restarted, the kubeletrestarts it, as with any other type of runtime failure.

阅读更多信息:https://kubernetes.io/docs/tasks/configure-pod-container/assign-memory-resource/#exceed-a-container-s-memory-limit

您可能还想阅读此内容:https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#how-pods-with-resource-limits-are-run

关于库伯内斯。如果请求大小大于 pod 的 RAM 会怎样?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73060773/

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