Neron Joseph
Neron Joseph

Reputation: 2385

How Kubernetes scheduler schedules pods with respect to resource limit and request?

I have a doubt about selecting the node for a pod in Kubernetes. Suppose, I have a node in Kubernetes with 2CPU and 8GB RAM. A pod is already running in the cluster and it's resource requirement is given below:

 resources:
    limits:
      cpu: 1
      memory: 4Gi
    requests:
      cpu: 0.5
      memory: 2Gi

In this case, I believe 0.5 out of 1 CPU and 2GiB out of 4GiB is reserved for this pod. In the case of "limit", this pod can go up to 1CPU and 4GiB RAM.

If I added a new pod with this resource requirement:

 resources:
    limits:
      cpu: 1.5
      memory: 6Gi
    requests:
      cpu: 0.5
      memory: 2Gi

will this pod can be allocated on the same node?

Here, if we are considering the requested amount of CPU and Memory, the Node is sufficient to schedule the pod.

i.e., Pod1 is using 0.5/2 CPU and 2/8GB Memory. And the new Pod2 is requesting the same 0.5cpu and 2GB memory. But if consider the limit, the total value is:

Pod1 CPU + Pod2 CPU (limit) = 1 + 1.5 = 2.5
Pod1 Memory + Pod2 Memory (limit) = 4 + 6 = 10GB

This exceeds the total resources.

In this case, how does the scheduling works? Thanks.

In other way, if the node has resources available for my requested resource but it doesn't have resources available for my limit of resource. In that case, does the scheduler schedules my pod to that node, or it will schedule my pod only on nodes that have the capacity to facilitate my limit as well?

Upvotes: 1

Views: 1760

Answers (2)

Deepak Mourya
Deepak Mourya

Reputation: 430

Hi @Neron Joseph If your new pod is requesting resources which is above the currently available resource on the node then your pod will be in a Pending state.

Ref: https://kubernetes.io/docs/tasks/configure-pod-container/assign-cpu-resource/#specify-a-cpu-request-that-is-too-big-for-your-nodes

Upvotes: 0

Jasonred8
Jasonred8

Reputation: 912

I think you can deploy the 2 resources in Kubernetes by that resource requirement although the requirement limit exceeds the total resources

but when your pods have really used the resources exceeding the system or your total node's resources, the pod will be killed by the system automatically.

the resource limit is available when your total node or your system has enough resources to use.

I think the Recourse Limit concept is like MySQL " between ... and ... LIMIT ..." for example:

we have 10 row data in one table, but I wrote the SQL to select select * from table where id between 0 and 100 LIMIT 1000

Upvotes: 0

Related Questions