...

/

Defining Container Memory and CPU Resources

Defining Container Memory and CPU Resources

Learn about CPU, memory, and other resource management terminology.

Getting familiar with the terminologies

So far, we have not specified how much memory and CPU containers should be used, 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 in 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.

Press + to interact
...
apiVersion: apps/v1
kind: Deployment
metadata:
name: go-demo-2-db
spec:
...
template:
...
spec:
containers:
- name: db
image: mongo:3.3
resources:
limits:
memory: 200Mi
cpu: 0.5
requests:
memory: 100Mi
cpu: 0.3
...
apiVersion: apps/v1
kind: Deployment
metadata:
name: go-demo-2-api
spec:
...
template:
...
spec:
containers:
- name: api
image: vfarcic/go-demo-2
...
resources:
limits:
memory: 100Mi
cpu: 200m
requests:
memory: 50Mi
cpu: 100m
...

We specified limits and requests entries in the resources section.

Understanding CPU resources

CPU resources are measured in cpu ...