Member-only story
Resource requirements in Kubernetes
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 AWS vCPU
- 1 GCP Core
- 1 Azure Core
- 1 Hyperthread
Also it is worth to mention that in memory specification, G means…