kubernetes - What's the difference between Pod resources.limits and resources.requests in Kubernetes?
问题描述
I've been reading the kubernetes documentation https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#resource-requests-and-limits-of-pod-and-container
But it's still not clear for me what's the difference between spec.containers[].resources.limits.cpu
and spec.containers[].resources.requests.cpu
and what's the impact on the resource limitation
Can you please suggest some reads or books where this is explained in common english?
Thanks in advance
解决方案
When Kubernetes pod is scheduled on a particular node it is required the pod to have enough resources to run. Kubernetes knows resources of it's node but how does kubernetes knows the how much resources will pod takes beforehand to schedule it effectively in nodes. For that requests
will be used. When we specify a request
of resource kubernetes will guarantee that pod will get that amount of resource.
On other hand limit
limits the resource usage by a pod. Kubernetes will not allow a pod to take more resources than the limit
. When it comes to CPU if you request more kubernetes will throttle pods CPU artificially. If pod exceed a limit
pod will be it will be terminated. To make it simple it simple limit
is always bigger than request
.
This example will give you idea about request
and limit
. Think that there is a pod where you have specify its memory request as 7GB and memory limit as 10GB. There are three nodes in your cluster where node1 has 2GB of memory, node2 has 8GB memory and node3 has 16GB. Your pod will never be scheduled on node1. But it will either be sceduled on node2 or node3 depending on pod current memory usage. But if it is scheduled on node3 it will be terminated in any scenario it will exceed the memory usage of 10GB.
推荐阅读
- javascript - 无法使用 useState 在数组中添加新项目,它会获得覆盖值
- jenkins - 如何在 Jenkins 管道上使用 BuildBlockerProperty
- c# - 将 double[,] 转换为 IntPtr C#
- android - Android Firestore 过滤器回收视图
- c# - .Net 5 项目 Docker COPY 文件未找到
- kubernetes - 使用域名而不是外部 ip 地址访问部署在 Kubernetes 上的服务
- csv - 使用 pyarrow.dataset 读取存储为 csv 的分区数据集
- python - 为什么 python 中的文档没有显示出来?
- filter - 布谷鸟过滤器必须使用 2 的下一个幂作为容量吗?
- r - R从长度不均匀的行输入文件创建对称矩阵