Junior — Middle
Have you ever configured resource limits in Kubernetes?
sobes.tech AI
Answer from AI
Yes, setting resource limits in Kubernetes is a common practice for controlling CPU and memory usage by containers.
In Kubernetes, you can specify:
- requests — the minimum guaranteed resources that a container will receive.
- limits — the maximum resources a container can use.
Example configuration in a Pod or Deployment manifest:
resources:
requests:
memory: "128Mi"
cpu: "250m"
limits:
memory: "256Mi"
cpu: "500m"
This helps to:
- Prevent a single container from consuming excessive resources.
- Ensure fair distribution of resources among applications.
- Improve cluster stability.
If a container exceeds its CPU limit, it will be throttled by the scheduler, and if it exceeds the memory limit, it may be killed (OOMKilled).