Skip to main content

☑️ Ensure each container has a configured memory limit

Memory limits enable you to use memory resources efficiently. By setting memory limits, you restrict the maximum amount of memory available to the pods running in your cluster.

Targeted objects by this rule (types of kind): Deployment / Pod / DaemonSet / StatefulSet / ReplicaSet / CronJob / Job

Complexity: hard (What does this mean?)

Policy as code identifier: CONTAINERS_MISSING_MEMORY_LIMIT_KEY


This rule will fail​

If a container doesn't have a memory limit configured

spec:
containers:
- name: app
image: nginx:1.19.8

Rule output in the CLI​

$ datree test *.yaml

>> File: failExample.yaml
❌ Ensure each container has a configured memory limit [1 occurrence]
💡 Missing property object `limits.memory` - value should be within the accepted boundaries recommended by the organization

How to fix this failure​

spec:
containers:
- name: app
image: nginx:1.19.8
resources:
limits:
memory: "128Mi"

Read more​