Yasser Rabee
Yasser Rabee

Reputation: 377

how to explicitly remove cpu limits for a container?

I want to remove cpu limits for a specific container where the namespace has default cpu limits (via limitrange). Per docs the default value will be assigned. When I explicitly set limits.cpu to 0, I got an error that tells me requests value 20m should be less than or equal to limits value.

So is it possible to force no limits in that case?

Upvotes: 4

Views: 5741

Answers (3)

Konstantin
Konstantin

Reputation: 37

Seems like you can remove limits with null value. At least it worked from helmfile:

   resources:
    requests:
      memory: "100Mi"
      cpu: "100m"
    limits:
      memory: "100Mi"
      cpu: null

Upvotes: 2

Yasser Rabee
Yasser Rabee

Reputation: 377

After more research, it is not possible to achieve. It does make sense to me it is not possible as stated by Frank Gu: because that would pretty much defeat the purpose of resource quotas in the first place

Upvotes: 1

Frank Yucheng Gu
Frank Yucheng Gu

Reputation: 1889

If you set the CPU limits to 0, then you will be getting <= 0 CPU resources. As per the link to the docs you have originally included, you should just set the request and not set the limit at all. That will set inform the scheduler of the pod's resource request. If your namespace has a CPU limit set, then the limit will be defaulted to that if it's not explicitly stated; otherwise, there will be no limit set.

Upvotes: 0

Related Questions