Resource requests and limits
Course: Kubernetes Part 3 (Scaling) - chapter 7
Ref - https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
When you specify a Pod, you can optionally specify how much of each resource a container needs. The most common resources to specify are CPU and memory (RAM).
There are two types of resource types
Resource requests
Section titled “Resource requests”The kubelet reserves at least the request amount of that system resource specifically for that container to use.
Resource limits
Section titled “Resource limits”When you specify a resource limit for a container, the kubelet enforces those limits so that the running container is not allowed to use more of that resource than the limit you set.
Difference b/w limits and requests
Section titled “Difference b/w limits and requests”If the node where a Pod is running has enough of a resource available, it’s possible (and allowed) for a container to use more resource than its request for that resource specifies. However, a container is not allowed to use more than its resource limit.
Experiments
Section titled “Experiments”30% CPU usage on a single threaded Node.js app
Update the spec from the last slide to decrease the CPU usage. Notice that the CPU doesnt go over 30% even though this is a Node.js app where it can go up to 100%
apiVersion: apps/v1kind: Deploymentmetadata: name: cpu-deploymentspec: replicas: 2 selector: matchLabels: app: cpu-app template: metadata: labels: app: cpu-app spec: containers: - name: cpu-app image: 100xdevs/week-28:latest ports: - containerPort: 3000 resources: requests: cpu: "100m" limits: cpu: "300m"Try hitting the server

Request 2 vCPU in 10 replicas
Try requesting more resources than available in the cluster.
apiVersion: apps/v1kind: Deploymentmetadata: name: cpu-deploymentspec: replicas: 10 selector: matchLabels: app: cpu-app template: metadata: labels: app: cpu-app spec: containers: - name: cpu-app image: 100xdevs/week-28:latest ports: - containerPort: 3000 resources: requests: cpu: "1000m" limits: cpu: "1000m"