Member-only story

Resource requirements in Kubernetes

Ishan Liyanage
2 min readDec 25, 2020

--

Lets take 3 nodes K8s cluster as an example. Each nod has a set of CPU, memory and disk resources. Every POD consumes a set of resources whenever we deployed it on any node in the cluster. It is the K8s scheduler that decides which nodes that POD will deploy.

The scheduler will consider the amount of CPU, Memory etc.. required by POD and place it. The scheduler will place the POD on node 2 if the node 1 has not sufficient resources to place the POD.

If there no sufficient resources available in any of the Nodes, K8s scheduler will hold back scheduling the POD. It will be in the pending state. If you see the events in POD, you will see the reason such as insufficient CPU, insufficient memory etc..

You can specify default CPU and Memory requirement by creating LimitRange object in Kubernetes.

If you know that your application will need more than these, you can specify the values you need in POD definition file.

You can specify then under the containers tag.

resources:
requests:
memory: "1Gi"
cpu: 1

The memory specification is somewhat meaningful. What is this 1 count of cpu really means?

1 count of CPU will be equivalent for

  1. 1 AWS vCPU
  2. 1 GCP Core
  3. 1 Azure Core
  4. 1 Hyperthread

Also it is worth to mention that in memory specification, G means…

--

--

Ishan Liyanage
Ishan Liyanage

Written by Ishan Liyanage

Passionate Technical Lead, Senior Software Developer and free and open source software advocate. Based in Singapore.

No responses yet

Write a response