Kubernetes Resource Requests and Limits

  • When scheduler tries to schedule a pod, k8s checks for pod's resource requirements and places on node which has sufficient resources
  • By default container requests for 0.5 CPU and 256 Mi of RAM for getting scheduled, this can be modified by adding resources section under spec of pod yaml definition
...
spec
  ...
  resources:
    requests:
      memory: "1Gi"
      cpu: 1
  • 1 CPU = 1000m = 1 vCPU = 1 AWS vCPU = 1 GCP core = 1 Azure core = 1 Hyperthread. m is millicore
  • It can as low as 0.1 which is 100m
  • For memory 1 K (kilobyte) = 1,000 bytes 1 M = 1,000,000 bytes 1 G = 1,000,000,000 bytes 1 Ki (kibibyte) = 1,024 bytes 1 Mi = 1,048,576 bytes ...
  • While container is running it's resource requirements can go high so by default k8s sets a limit of 1 vCPU and 512 Mi to containers, this can also be changed by adding limits section under resources section
...
spec:
  resources:
    ...
    limits:
      memory: "2Gi"
      cpu: 2
  • If container tries to use more CPU then limits, then it is throttled and in case if memory exceeds container is terminated

You'll only receive email when they publish something new.

More from mojozoox
All posts