Defining container memory and CPU resources

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".

Let's take a look at a modified go-demo-2 definition:

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:

... apiVersion: apps/v1beta2 kind: Deployment metadata: name: go-demo-2-db spec: ... template: ... spec: containers: - name: ...

Get The DevOps 2.3 Toolkit now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.