5
votes

There's a bit of a vagueness in the Kubernetes documentation about what happens if a pod's memory footprint increases to a point where it exceeds the value specified under resources.limits.

https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#how-pods-with-resource-limits-are-run

It specifies that if a pod's footprint grows to exceed its limits value, it "might be" terminated. What does the "might be" mean? What conditions would result in it being terminated vs which ones would allow it to continue on as-is?

2
AFAIK you'll experience pods OOM killed and thus stopped. Now if you're referring to request limits simply pods will be evicted and won't be able to be scheduledHernan Garcia

2 Answers

5
votes

Q: What happens if a Kubernetes pod exceeds its memory resources 'limit'?

It will be restarted.

Unlike Pod eviction, if a Pod container is OOM killed, it may be restarted by the kubelet based on its RestartPolicy.

You can Configure Out Of Resource Handling for your Node.

Evicting end-user Pods

If the kubelet is unable to reclaim sufficient resource on the node, kubelet begins evicting Pods.

The kubelet ranks Pods for eviction first by whether or not their usage of the starved resource exceeds requests, then by Priority, and then by the consumption of the starved compute resource relative to the Pods’ scheduling requests.

1
votes

Limits refers to memory and cpu. If memory consumption increases it will be terminated but in case of CPU, os can allow tiny time slices to consume more than allowed CPU share.