---
title: "Set resource requests and a memory limit · Agent Wranglers"
url: https://agentwranglers.se/playbook/infrastructure/containers-and-orchestration/kubernetes-requests-and-limits
id: INF-79
level: Required
applies: servers
risk: outage
updated: 2026-10-27
build: a2a6bdfed830
tokens: 1079
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Set resource requests and a memory limit on every container

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Containers and orchestration](https://agentwranglers.se/playbook/infrastructure/containers-and-orchestration.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

- ID: INF-79
- Level: Required
- Chapter: [Containers and orchestration](https://agentwranglers.se/playbook/infrastructure/containers-and-orchestration.md)
- Rule: Give every container a CPU and memory request from measured use, and a memory limit. Set a default in each namespace, so a container without them is refused or gets one.
- Check: A policy check on the manifests fails any container without a CPU request, a memory request and a memory limit. Every namespace has a `LimitRange`. The count of containers killed for running out of memory over the last 7 days is 0, or each one has a ticket.
- Risk: The app down or unusable
- Applies when: The project runs its own servers, virtual machines or containers.
- How: The scheduler places pods by their requests. A pod without one can land on a full node and starve its neighbours. A container that passes its memory limit is killed and restarted. Without a limit, a leak takes memory from every pod on the node. Set the memory request near the measured peak, and the limit at about the same value, so the node never runs out. Many teams leave the CPU limit out, because CPU throttling slows requests while spare CPU sits idle. Set a `LimitRange` per namespace for defaults and a `ResourceQuota` for the namespace total. The autoscaler's CPU target is a share of the request, so requests also drive [Scale on the resource that runs out](https://agentwranglers.se/playbook/scaling/load-balancing-and-autoscaling/scale-on-saturation.md). Size the runtime's heap below the limit, as [Size the runtime's memory to the box](https://agentwranglers.se/playbook/operations/capacity-and-resilience/runtime-memory-limits.md) says. Hosts without Kubernetes follow [Set limits on memory and processes](https://agentwranglers.se/playbook/operations/running-the-service/resource-limits.md).

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### YAML example

```yaml
resources:
  requests: { cpu: 250m, memory: 384Mi }
  limits: { memory: 384Mi }
---
apiVersion: v1
kind: LimitRange
metadata: { name: defaults, namespace: shop }
spec:
  limits:
    - type: Container
      defaultRequest: { cpu: 100m, memory: 128Mi }
      default: { memory: 256Mi }
```

## Sources

- [Kubernetes, Resource management for pods and containers](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/)

## Related rules

- SCL-30 [Scale on the resource that runs out](https://agentwranglers.se/playbook/scaling/load-balancing-and-autoscaling/scale-on-saturation.md) in Scaling
- OPS-41 [Size the runtime's memory to the box](https://agentwranglers.se/playbook/operations/capacity-and-resilience/runtime-memory-limits.md) in Operations and observability
- OPS-34 [Set limits on memory and processes](https://agentwranglers.se/playbook/operations/running-the-service/resource-limits.md) in Operations and observability

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/infrastructure/containers-and-orchestration/kubernetes-requests-and-limits">Agent Wranglers infrastructure and environments playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Probe every Kubernetes workload for readiness and liveness](https://agentwranglers.se/playbook/infrastructure/containers-and-orchestration/kubernetes-probes.md)
- Next: [Keep enough copies running through planned disruptions](https://agentwranglers.se/playbook/infrastructure/containers-and-orchestration/pod-disruption-budgets.md)
- [Containers and orchestration](https://agentwranglers.se/playbook/infrastructure/containers-and-orchestration.md)
