panchalhimself

Resource requests in kubernetes.

19 June 2023

Resource requests: resource usage definition that a container needs to be deployed.

Resource requests only affect scheduling of the containers based on the set resource request limit. So essentially containers can utilize the resources as per their requirements once they are scheduled.

    resources:
      requests:
        memory: "100Mi"
        cpu: "250m"

Resource limits: Utilisation limits for containers, container runtime is responsible for enforcing these set limits.

Different container runtimes handle these resource limits differently. Some runtimes will enforce these by terminating the container process that overuses the resources past the set limit.

    resources:
      limits:
        memory: "200Mi"
        cpu: "500m"

nginx.yaml

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: nginx
  name: nginx
spec:
  containers:
  - image: nginx
    name: nginx
    resources:
      requests:
        memory: "100Mi"
        cpu: "250m"
      limits:
        memory: "200Mi"
        cpu: "500m"

  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}

I will be adding how I searched this on the documentation page as well.

k8s exam will allow use of the official documentation.

search query: limits and requests

key page: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/