Container Resource Requirements
Kubernetes allows you to specify the CPU and memory requirements for a container. As part of the
Pod spec you can specify CPU and memory
- the CPU and memory resources required to run a container
- used by Kubernetes to decide what worker
Pod should be deployed to. This ensures there are sufficient resources on the
Node to run the
- an upper limit for the resource usage of a container
- if a container exceeds these limits it will likely be destroyed.
- stops individual containers monopolising resources on a
limits are defined beneath
resources in the
- name: container-resources-pod-demo
command: [ "sh", "-c", "echo hello pod security & sleep 3600" ]
Requested memory is
32Mi (32 Mebibytes) which is approximately 32 megabytes. Allowed memory is capped at
CPU is measured in cores. The requested CPU is
400m which represents 400 milliCPUs or 0.4 CPU cores. The upper CPU limit is capped at
600m or 600 milliCPUs.
After running the above
Pod you can use
kubectl describe to see the resource requirements in the running container.
The sample code for these notes is available here.