Middle+
How do you determine the values of requests and limits for resources in Kubernetes?
sobes.tech AI
Answer from AI
The values of requests and limits for resources in Kubernetes are determined based on the application's resource consumption analysis and stability requirements.
- Requests — the minimum guaranteed resources that a pod will receive upon startup. Usually set at the level of the application's average consumption.
- Limits — the maximum resources that a pod can use. They help restrict consumption and prevent impact on other pods.
To determine these values:
- Collect CPU and memory usage metrics under real conditions (e.g., using Prometheus).
- Analyze peak and average values.
- Set
requestsslightly above the average consumption to ensure stability. - Set
limitsat a level that prevents the application from overloading the node, considering peak loads.
Example in a Kubernetes manifest:
resources:
requests:
cpu: "100m"
memory: "200Mi"
limits:
cpu: "500m"
memory: "500Mi"
This approach helps balance resource utilization efficiency and application stability.