>_ IzzyLab

Hands-on task

This task is step 16 of the course “Kubernetes: manifests from Namespace to RBAC”

Resource limits in a Deployment

easy~11 min

/root/limited.yaml already describes a working Deployment api (image nginx:1.27-alpine), but the container has no resources set — in prod that's dangerous. Open the file in the Editor tab and give the container requests (cpu 100m, memory 128Mi) and limits (cpu 500m, memory 256Mi). Then apply the manifest to this sandbox's Kubernetes cluster (kubectl is already configured), wait until it's ready and see which QoS class the pod got.

What you'll practise:
  • kubernetes
  • deployment
  • resources
  • requests-limits
  • yq
  • qos
  • kubectl apply

Topic breakdown

A container in Kubernetes has two levels of resources: requests — the guaranteed minimum the scheduler uses to pick a node, and limits — the ceiling: going over the memory limit ends in OOMKilled, going over the CPU limit gets the container throttled. Both blocks live in spec.template.spec.containers[].resources, and the values are strings: CPU in millicores (100m = 0.1 core), memory with the Mi suffix (mebibytes). Without limits a single pod can eat the resources of the whole node — that's why in prod they're always set. From how requests relate to limits, Kubernetes gives the pod a QoS class: Guaranteed (every container has requests equal to limits), Burstable (something is set, but not equal) or BestEffort (nothing is set). When a node runs out of memory, BestEffort pods are evicted first and Guaranteed ones last.

What's checked

  1. Manifest is valid
  2. limit cpu 500m
  3. request memory 128Mi
  4. request cpu 100m, limit memory 256Mi
  5. Deployment api with resources is applied and ready
  6. the api pod got the Burstable QoS class

What it looks like