What is the purpose of resource limit in Kubernetes?

1/24/2019

It is known that if a pod consumed more resource than request, it is likely to be evicted or terminated. What is the purpose of resource limit then? Is it like a grace period?

  resources: 
    requests:
      cpu: "100m"
    limits:
      cpu: "200m"

I didn't see a clear documentation for this in Kubernetes official doc. Can anyone clarify this?

-- Jawahar
containers
kubernetes
microservices

2 Answers

1/24/2019

Limits guarantee that the container will never overreach the defined value for a particular resource. You can always set LimitRange whenever you want to define the default request limits for containers within the same namespace, use Min and Max Resource Constraints or even set Memory and CPU Quotas for the particular namespace as described here. There are also some concepts of using Limits for Namespace mentioned in the official Kubernetes documentation.

-- mk_sta
Source: StackOverflow

1/24/2019

Request guarantees a minimum amount of resource, which the scheduler does by ensuring the node that the Pod is scheduled to has space for it. Limit is a maximum over which a Pod is like to be killed.

I personally find the google kubernetes documentation clearer on this than the official kubernetes one.

-- Ryan Dawson
Source: StackOverflow