Skip to Content
Kubernetes即学即用(第二版)
book

Kubernetes即学即用(第二版)

by Brendan Burns, Joe Beda, Kelsey Hightower
June 2021
Intermediate to advanced
300 pages
5h 4m
Chinese
China Electric Power Press Ltd.
Content preview from Kubernetes即学即用(第二版)
74
5
内存请求的处理方式与
CPU
类似,但二者有一个重要的区别。如果容器使
用的内存量超出请求,则操作系统无法简单地从进程中删除内存,因为内存
已被分配出去了。因此,当系统内存不足时,
kubelet
会终止内存使用量大
于请求值的容器。这些容器会自动重启,但该容器能使用的内存量会减少。
由于资源请求可以保证
Pod
获得所需的资源,因此,资源请求至关重要,因
为它能确保容器在高负载情况下仍然有足够的资源。
5.7.2
通过约束限制资源使用量
除了设置
Pod
所需的资源量(确保
Pod
所需的最小资源量)之外,你还可以
通过资源约束设置
Pod
的最大资源使用量。
在前面的示例中,我们创建了一个
kuard Pod
,该
Pod
至少需要
0.5
个内核和
128 MB
内存。在示例
5-4
Pod
清单中,我们扩展了这个配置,并添加了
1.0
CPU
内核以及
256 MB
内存的约束。
示例
5-4
kuard-pod-reslim.yaml
apiVersion: v1
kind: Pod
metadata:
name: kuard
spec:
containers:
- image: gcr.io/kuar-demo/kuard-amd64:blue
name: kuard
resources:
requests:
cpu: "500m"
memory: "128Mi"
limits:
cpu: "1000m"
memory: "256Mi"
ports: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PyTorch深度学习

PyTorch深度学习

Posts & Telecom Press, Vishnu Subramanian
Python数据分析

Python数据分析

Posts & Telecom Press, Ivan Idris
Python贝叶斯分析(第2版)

Python贝叶斯分析(第2版)

Posts & Telecom Press, Osvaldo Martin
Python高级编程(第2版)

Python高级编程(第2版)

Posts & Telecom Press, Michał Jaworski, Tarek Ziadé

Publisher Resources

ISBN: 9787519856762