What are requests and limits in Kubernetes? What does requests specify?
sobes.tech AI
Answer from AI
In Kubernetes, requests and limits are parameters that specify the resources (CPU, memory) a container can use.
-
requests — the minimum guaranteed amount of resources that will be allocated to the container. The Kubernetes scheduler uses these values to decide on which node to place the pod. If the container needs more resources than specified in requests, it can get them if they are available.
-
limits — the maximum resource limit that the container cannot exceed. If the container tries to use more CPU than the limit, its usage will be restricted. For memory, exceeding the limit may lead to the container being terminated (OOMKilled).
Example:
resources:
requests:
cpu: "500m" # 0.5 CPU
memory: "256Mi"
limits:
cpu: "1"
memory: "512Mi"
Here, the container is guaranteed to get 0.5 CPU and 256Mi of memory, but cannot use more than 1 CPU and 512Mi of memory.