Defining Container Memory and CPU Resources
In this lesson, we will get familiar with the CPU, memory and other resource management terminologies.
Getting Familiar with the Terminologies
So far, we did not specify how much memory and CPU containers should use, nor what their limits should be. If we do that, Kubernetes’ scheduler will have a much better idea about the needs of those containers, and it’ll make much better decisions on which nodes to place the Pods and what to do if they start “misbehaving”.
Looking into the Definition
Let’s take a look at a modified go-demo-2
definition.
Press + to interact
cat res/go-demo-2-random.yml
The specification is almost the same as those we used before. The only new entries are in the resources
section.
The output, limited to the relevant parts, is as follows.
Press + to interact
...apiVersion: apps/v1beta2kind: Deploymentmetadata:name: go-demo-2-dbspec:...template:...spec:containers:- name: dbimage: mongo:3.3resources:limits:memory: 200Micpu: 0.5requests:memory: 100Micpu: 0.3...apiVersion: apps/v1beta2kind: Deploymentmetadata:name: go-demo-2-apispec:...template:...spec:containers:- name: apiimage: vfarcic/go-demo-2...resources:limits:memory: 100Micpu: 200mrequests:memory: 50Micpu: 100m...
We specified limits
and requests
entries in the resources
section.
Understanding CPU
...Access this course and 1400+ top-rated courses and projects.