Skip to main content
In this lesson you’ll add resource requests and limits to the carts-db Deployment (part of the Sock Shop demo) so the container has guaranteed CPU/memory and a capped memory usage. Below is a complete Deployment manifest that shows where to add resources.requests and resources.limits, along with the container image, ports, environment variables, and an in-memory emptyDir volume.
What this manifest configures:
  • Requests: cpu: "250m", memory: "64Mi" — guaranteed resources used by the scheduler when placing the Pod.
  • Limits: memory: "128Mi" — maximum memory the container may use. (No CPU limit specified here, so the container can burst CPU beyond 250m if node capacity allows.)
Summary table How to apply this in the OpenShift web console
  1. Open the OpenShift console in your course environment: https://learn.kodekloud.com/user/courses/openshift-4.
  2. In the Administrator view navigate to Workloads → Deployments.
  3. Click Create Deployment and switch to the YAML editor.
  4. Paste the manifest above and create the Deployment.
A Red Hat OpenShift web console screenshot showing the "Deployments" page for the "default" project with the message "No Deployments found" and a blue "Create Deployment" button. The left-hand navigation menu and administrator header are also visible.
After creating the Deployment, OpenShift will create the Pod for it. Wait a moment — the Deployments page should show the Deployment with one running pod:
A screenshot of the Red Hat OpenShift web console showing the "carts-db" deployment details in the default project. A circular status chart shows one running pod for that deployment.
Inspect the Pod to confirm it’s Running and to view the applied resource settings. From the Pod details page you can open the Pod YAML and confirm the resources block is present.
A screenshot of the Red Hat OpenShift web console showing the Pod details page for "carts-db-dff84c9cd-cnhsv" in the default project with status "Running." The left sidebar shows the Administrator menu with Workloads → Pods selected.
Example excerpt from the PodSpec (what you should see in the Pod YAML):
Why use requests and limits?
  • Requests ensure the scheduler reserves node capacity for your Pod.
  • Limits prevent containers from consuming excessive resources and impacting other workloads.
  • Omitting CPU limits allows CPU bursting, but scheduling still uses the request value.
For cluster-wide enforcement, use ResourceQuotas (Kubernetes) or project quotas (OpenShift) to enforce aggregate limits per namespace so you don’t have to set requests/limits on every single Deployment manually. See:
Resource requests reserve capacity on a node and influence scheduling; limits cap the maximum usage. Setting sensible requests and limits helps cluster stability and prevents noisy neighbors. If you omit a CPU limit, the container may burst CPU usage (subject to the node’s available CPU) but the scheduler will use the request value when placing the Pod.

Watch Video