Description
A container without an effective memory limit can exhaust its node’s memory. Check the container limit, namespace LimitRange defaults and any Pod-level limit supported by your cluster.
Potential impact
A memory leak can slow other Pods or lead to evictions under node memory pressure. A limit that is too low can instead cause an out-of-memory (OOM) termination within the container.
Remediation
- Set
resources.limits.memoryfrom observed workload needs. Review it with the memory request used for scheduling. - Monitor usage and OOM events under load, then adjust the limit as demand changes.
Examples
Provide the stress image’s arguments and any required CPU request. Adjust the example memory values to your workload.
Before
yaml
apiVersion: v1
kind: Pod
metadata:
name: memory-demo-1
spec:
containers:
- name: memory-demo-ctr
image: polinux/stress
resources:
requests:
cpu: "0.5"
After
yaml
apiVersion: v1
kind: Pod
metadata:
name: memory-demo-safe
spec:
containers:
- name: memory-demo-ctr
image: polinux/stress
resources:
limits:
memory: "200Mi"
requests:
memory: "100Mi"
Explanation:
- Before: The container specifies only a CPU request. Check whether a default or Pod-level memory limit applies.
- After: The memory request is
100Miand the limit is200Mi.