Relation between LimitRange's default, defaultRequest, max and min limits

4/22/2020

I do not understand kubernetes LimitRange configuration. I created a manifest with following contents:

apiVersion: v1
kind: LimitRange
metadata:
  name: cpu-limit-range
spec:
  limits:
  - default:
      cpu: 4
    defaultRequest:
      cpu: 4
    max:
      cpu: 6

    type: Container

And then I run following commands :

[root@localhost ~]# kubectl  delete  pods default-cpu-demo-19 1^C
[root@localhost ~]# kubectl  get pods  -n=limit
NAME                  READY   STATUS    RESTARTS   AGE
default-cpu-demo-19   0/1     Pending   0          9s
[root@localhost ~]# kubectl  describe pods   -n=limit
......(omitted unnecessary echo here)......
  Type     Reason            Age                 From               Message
  ----     ------            ----                ----               -------
  Warning  FailedScheduling  14s (x8 over 9m2s)  default-scheduler  0/1 nodes are available: 1 Insufficient cpu.

Of course, I know that most amount of limit:cpu of a container can not be more bigger than that of above configuration. Otherwise, kubernets will report insufficient cpu.

And yet most amount of max:cpu of a container can not be bigger than that of above configuration as well.

I can't distinguish between maximum and limit, because a value is bigger than the limit or max is not allowed.

So, I want to know what they represent respectively and relation among them.

-- zhangqichuan
docker
kubernetes

1 Answer

4/23/2020

If i understand your question correctly, what you asked is -- what's the difference between min, max, default and defaultRequest limits for containers set in LimitRange resource. The answer is very simple:

  • defaultRequest — is how much CPU/Memory will be given to Container, if it doesn't specify it's own value
  • default — is default limit for amount of CPU/Memory for Container, if it doesn't specify it's own value
  • max — is maximum limit for amount of CPU/Memory that Container can ask for. I.e. it can't set it's own limit more than that
  • min — is minimum limit amount of CPU/Memory that Container can ask for. I.e. it can't set it's own limit less than that

Here is part of official documentation that has examples and more info on that topic.

-- Grigoriy Mikhalkin
Source: StackOverflow